Wednesday, October 15, 2008
I just posted article about "Economic Slowdown, JOB CUTs and Software Developer." I wish everybody should not to be in situation to read this.....
More relaxing jobs are more
dangerous: Economic Slowdown, JOB CUTs and Software Developer
Friday, September 19, 2008
1. What is DESCRIBE command in SQL Server 2005? What is its purpose? How to use it?
DESCRIBE is used to see table structure. In SQL server 2005 we can use sp_columns, sp_tables or sp_help.
sp_columns
will show list of columns and its details in table.
sp_tables will show list of tables in the databas
2. What is RDBMS?
Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships created and maintained across tables between data. Interdependencies between these tables are defined by the data values.
RDMS is based upon relational modal of E.F.Codd
3. Can UNIQUE KEY in SQL Server 2005 have two or more NULL?
SQL server 2005 can not have more then one NULL, because in SQL server 2005 every null is having same value. UNIQUE KEY in ORACLE can have more then one NULL values as every NULL in ORACLE is having unique value.
4. What is a "trigger" in SQL Server 2005?
In any database including SQL Server 2005 a trigger is procedure that initiates on INSERT, DELETE or UPDATE actions. Before SQL Server 2000 Triggers are also used to maintain the referential integrity. We can not execute triggers explicitly; the DBMS automatically fires the trigger when data modification events (INSERT, DELETE or UPDATE) happened in the associated table.
Triggers are same as stored procedures in term of procedural logic that is stored at the database level. Stored procedures are executed explicitly and triggers are event-drive.
Triggers can also execute stored procedures.
Nested Trigger: A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger. See Create Trigger for more
5. What is View in Database (SQL Server 2005, ORACLE)?
As per the theory of database (which includes SQL Server 2005, Oracle etc.) a view can be thought of stored SQL query which result can be accessible as a table. It can be used for retrieving data, as well as updating or deleting rows.
But database view does not have physical schema
The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.
See more on Database Views
6. How do you optimize stored procedures in SQL Server 2005?
1. Use as much as possible WHERE clause filters. Where Clause is the most important part for optimization
2. Select only those fields which really require.
3. Joins are expensive in terms of time. Make sure that use all the keys that relate the two tables together and don't join to unused tables, always try to join on indexed fields. The join type is important as well (INNER, OUTER).
7. How is the error handling in stored procedures of SQL Server 2005?
In previous versions of SQL Server you would handle exceptions by checking the @@error global variable immediately after an INSERT, UPDATE or DELETE, and then perform some corrective action if @@error did not equal zero.
SQL Server 2005 provides structured exception handing through TRY CATCH block as other programming language like JAVA, C# etc.
BEGIN TRY
RAISERROR ('Yaa, I ma the problem', 16,1)
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() as ERROR_NUMBER,
ERROR_SEVERITY() as ERROR_SEVERITY,
ERROR_STATE() as ERROR_STATE,
ERROR_MESSAGE() as ERROR_MESSAGE
END CATCH
ERROR_NUMBER() returns the number of the error.
ERROR_SEVERITY() returns the severity.
ERROR_STATE() returns the error state number.
ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred.
ERROR_LINE() returns the line number inside the routine that caused the error.
ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters, such as lengths, object names or times.
More on SQL Server 2005 interview questions
Monday, June 09, 2008
Former President of India APJ Abdul Kalam at Wharton India Economic forum , Philadelphia, United States March 22,2008)
Question: Could you give an example, from your own experience, of how leaders should manage failure?
Kalam: Let me tell you about my experience. In 1973 I became the project director of India's satellite launch vehicle program, commonly called the SLV-3. Our goal was to put India's "Rohini" satellite into orbit by 1980. I was given funds and human resources -- but was told clearly that by 1980 we had to launch the satellite into space. Thousands of people worked together in scientific and technical teams towards that goal.
By 1979 -- I think the month was August -- we thought we were ready. As the project director, I went to the control center for the launch. At four minutes before the satellite launch, the computer began to go through the checklist of items that needed to be checked. One minute later, the computer program put the launch on hold; the display showed that some control components were not in order. My experts -- I had four or five of them with me -- told me not to worry; they had done their calculations and there was enough reserve fuel. So I bypassed the computer, switched to manual mode, and launched the rocket. In the first stage, everything worked fine. In the second stage, a problem developed. Instead of the satellite going into orbit, the whole rocket system plunged into the Bay of Bengal. It was a big failure.
That day, the chairman of the Indian Space Research Organization, Prof. Satish Dhawan, had called a press conference. The launch was at 7:00 am, and the press conference -- where journalists from around the world were present -- was at 7:45 am at ISRO's satellite launch range in Sriharikota [in Andhra Pradesh in southern India]. Prof. Dhawan, the leader of the organization, conducted the press conference himself. He took responsibility for the failure -- he said that the team had worked very hard, but that it needed more technological support. He assured the media that in another year, the team would definitely succeed. Now, I was the project director, and it was my failure, but instead, he took responsibility for the failure as chairman of the organization.
The next year, in July 1980, we tried again to launch the satellite -- and this time we succeeded. The whole nation was jubilant. Again, there was a press conference. Prof. Dhawan called me aside and told me, "You conduct the press conference today."
I learned a very important lesson that day. When failure occurred, the leader of the organization owned that failure. When success came, he gave it to his team. The best management lesson I have learned did not come to me from reading a book; it came from that experience….
Monday, June 02, 2008
Friday, May 23, 2008
I did quick test to check which browser eats more memory. My test is not so robust. I only open 4 similar pages into all the browser and check the memory uses into Window task manager. What I found Safari eats more memory then IE 7 and least memory consume by Firefox. I am not saying this test is a sufficient test for browsers. Here is snapshot.
Thursday, January 10, 2008
ASP.NET 2.0 Interview Questions
1. What is the name of the property of ASP.NET page that you can query to determine that a ASP.NET page is being requested not data being submitted to web server?
A. FirstGet
B. Initialized
C. IncludesData
D. IsPostBack
IsPostBack
2. While creating a Web site with the help of Visual Studio 2005 on a remote computer that does not have Front Page Server Extensions installed, which Web site type will you create in Visual Studio 2005?
A. Remote HTTP
B. File
C. FTP
D. Local HTTP
Hypertext Transfer Protocol (HTTP)
3. If you want to create a new Web site with the help of Visual Studio 2005 on a Web server that is hosted by your ISP (Internet Services provider) and the Web server has Front Page Server Extensions installed, what type of Web site type would you create in Visual Studio 2005?
A. Local HTTP
B. File
C. FTP
D. Remote HTTP
Hypertext Transfer Protocol (HTTP)
4. For separating server-side code from client-side code on a ASP.NET page, what programming model should you use?
A. Separation model
B. Code-Behind model
C. In-Line model
D. ClientServer model
5. Amit created a new Web site using Visual Studio 2005 in programming language C#. Later, Amit received an existing Web page from his boss, which consisted of the Contact.aspx file with the Contact.aspx.vb code-behind page. What must Amit do to use these files?
A. Amit can simply add the files Contact.aspx, Contact.aspx.vb into the existing Web site, because ASP.NET 2.0 supports Web sites that have Web pages that were programmed with different languages.
B. The Contact.aspx file will work, but Amit must rewrite the code-behind page using C#.
C. Both files Contact.aspx and Contact.aspx.vb must be rewritten in C#.
D. Amit must create a new Web site that contains these files Contact.aspx and Contact.aspx.vb. Set a Web reference to the new site.
6. If you want to make a configuration setting change in your server that will affect to all Web and Windows applications on the current machine. Where you will make the changes?
A. Global.asax
B. Web.config
C. Machine.config
D. Global.asax
7. If you want to make a configuration setting change that will affect only the current Web application. Which file will you change?
A. Web.config that is in the same folder as the Machine.config file
B. Web.config in the root of the Web application
C. Machine.config
D. Global.asax
8. For making a configuration setting change that will affect only the current Web application. Is there any tool that has a user-friendly Graphical User Interface (GUI)?
A. The Microsoft Management Utility
B. Microsoft Word
C. Visual Studio, using the Tools > Options path
D. Web Site Administration Tool
ASP.NET 2.0 Interview Questions
9. How will you identify which event in the ASP.NET Web page life cycle takes the longest time to execute?
A. Turn on ASP.NET trace and run the Web application.
B. Add a few code to each of the page life-cycle events that will print the current time.
C. In the Web.config file, add the monitorTimings attribute and set it to True.
D. In the Web site properties, turn on the performance monitor and run the Web application. After that, open performance monitor to see the timings.
11. You are interested in examining the data that is posted to the Web server. What trace result section can you use to see this information?
A. Control Tree
B. Headers Collection
C. Form Collection
D. Server Variables
12. While creating web site you need to add an HTML Web server control to the Web page, you need to drag an HTML element from the ToolBox of Visual Studio 2005 to the Web page and then which of the following tasks you will perform?
A. Right-click the HTML element and click Run=Server.
B. Double-click the HTML element to convert it to an HTML server control.
C. Right-click the HTML element and click Run As Server Control.
D. Click the HTML element and set ServerControl to true in the Properties window.
13. While testing your ASP.NET web application you noticed that while clicking on CheckBox of one of the web page it does not cause a PostBack; you required that the CheckBox should make PostBack so Web page can be update on the server-side code. How can you make the CheckBox to cause a PostBack?
A. Set the AutoPostBack property to true.
B. Add JavaScript code to call the ForcePostBack method.
C. Set the PostBackAll property of the Web page to true.
D. Add server-side code to listen for the click event from the client.
14. While writing code in Visual Studio 2005 you creates a new instance of a ASP.NET TextBox server control, what do you need to do to get the TextBox to display on the Web page?
A. Call the ShowControl method on the TextBox.
B. Set the VisibleControl to true on the TextBox.
C. Add the TextBox instance to the form1.Controls collection.
D. Execute the AddControl method on the Web page.
15. While creating your ASP.NET web based application you want to create multiple RadioButton server controls which should be mutually exclusive, what property of RadioButton server controls you must set?
A. Exclusive
B. MutuallyExclusive
C. Grouped
D. GroupName
16. While creating an ASP.NET web application with the help of Visual Studio 2005 you are creates a Web page that has several related buttons, such as fast-forward, reverse, play, stop, and pause. There should be one event handler that handles the processes of PostBack from these Button server controls. Other than the normal Submit button, what type of button can you create?
A. OneToMany
B. Command
C. Reset
D. ManyToOne
ASP.NET 2.0 Interview Questions
17. In the Design view in Visual Studio 2005 of an ASP.NET web page, what is the easiest way to create an event handler for the default event of a ASP.NET server control?
A. Open the code-behind page and write the code.
B. Right-click the control and select Create Handler.
C. Drag an event handler from the ToolBox to the desired control.
D. Double-click the control.
18. Which of the following represents the best use of the Table, TableRow, and Table-Cell controls?
A. To create and populate a Table in Design view
B. To create a customized control that needs to display data in a tabular fashion
C. To create and populate a Table with images
D. To display a tabular result set
19. For your ASP.NET web application your graphics designer created elaborate images that show the product lines of your company. Some of graphics of the product line are rectangular, circular, and others are having complex shapes. You need to use these images as a menu on your Web site. What is the best way of incorporating these images into your Web site?
A. Use ImageButton and use the x- and y-coordinates that are returned when the user clicks to figure out what product line the user clicked.
B. Use the Table, TableRow, and TableCell controls, break the image into pieces that are displayed in the cells, and use the TableCell control’s Click event to identify the product line that was clicked.
C. Use the MultiView control and break up the image into pieces that can be displayed in each View control for each product line. Use the Click event of the View to identify the product line that was clicked.
D. Use an ImageMap control and define hot spot areas for each of the product lines. Use the PostBackValue to identify the product line that was clicked.
20. You are writing ASP.NET 2.0 Web site that collects lots of data from users, and the data collection forms spreads over multiple ASP.NET Web pages. When the user reaches the last page, you need to gather all of data, validate the data, and save the data to the SQL Server database. You have noticed that it can be rather difficult to gather the data that is spread over multiple pages and you want to simplify this application. What is the easiest control to implement that can be used to collect the data on a single Web page?
A. The View control
B. The TextBox control
C. The Wizard control
D. The DataCollection control
21. In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?
A. Use the ImageMap control and randomly select a HotSpot to show or hide.
B. Use the Image control to hold the image and a Calendar control to randomly select a date for each image to be displayed.
C. Use the AdServer control and create an XML file with configuration of the control.
D. Use an ImageButton control to predict randomness of the image to be loaded based on the clicks of the control.
22. In your ASP.NET web application you want to display a list of clients on a Web page. The client list displays 10 clients at a time, and you require the ability to edit the clients. Which Web control is the best choice for this scenario?
A. The DetailsView control
B. The Table control
C. The GridView control
D. The FormView control
23. While developing ASP.NET 2.0 web application you want to display a list of parts in a master/detail scenario where the user can select a part number using a list that takes a minimum amount of space on the Web page. When the part is selected, a DetailsView control displays all the information about the part and allows the user to edit the part. Which Web control is the best choice to display the part number list for this scenario?
A. The DropDownList control
B. The RadioButtonList control
C. The FormView control
D. The TextBox control
ASP.NET 2.0 Interview Questions
24. While developing ASP.NET 2.0 web application you have a DataSet containing a Customer DataTable and an Order DataTable. You want to easily navigate from an Order DataRow to the Customer who placed the order. What object will allow you to easily navigate from the Order to the Customer?
A. The DataColumn object
B. The DataTable object
C. The DataRow object
D. The DataRelation object
25. Which of the following is a requirement when merging modified data into a DataSet?
A. A primary key must be defined on the DataTable objects.
B. The DataSet schemas must match in order to merge.
C. The destination DataSet must be empty prior to merging.
D. A DataSet must be merged into the same DataSet that created it.
26. You are working with a DataSet and want to be able to display data, sorted different ways. How do you do so?
A. Use the Sort method on the DataTable object.
B. Use the DataSet object’s Sort method.
C. Use a DataView object for each sort.
D. Create a DataTable for each sort, using the DataTable object’s Copy method, and then Sort the result.
27. Which of the following ways can you proactively clean up a database connection’s resources?
A. Execute the DbConnection object’s Cleanup method.
B. Execute the DbConnection object’s Close method.
C. Assign Nothing (C# null) to the variable that references the DbConnection object.
D. Create a using block for the DbConnection object.
29. What event can you subscribe to if you want to display information from SQL Print statements?
A. InfoMessage
B. MessageReceived
C. PostedMessage
D. NewInfo
30. To perform asynchronous data access, what must be added to the connection string?
A. BeginExecute=true
B. MultiThreaded=true
C. MultipleActiveResultSets=true
D. Asynchronous=true
31. Which class can be used to create an XML document from scratch?
A. XmlConvert
B. XmlDocument
C. XmlNew
D. XmlSettings
32. Which class can be used to perform data type conversion between .NET data types and XML types?
A. XmlType
B. XmlCast
C. XmlConvert
D. XmlSettings
MORE POST:
SQL Server 2005 Interview Question
Resource:
ASP.NET 2.0
Distributed Authoring and Versioning (DAV)
http methods
Multipurpose Internet Mail Extensions (MIME) type
PostBack
QueryString
request
response
Web browser
Web Form
Web server
HTML server control
ViewState
Web server control
ACID properties
connection pooling
DataColumn
DataRow
DataTable
DiffGram
Document Object Model (DOM)
Thursday, January 03, 2008
VB.NET and C# Syntax Comparison
|
|
Imports System
Namespace HelloNamespace
Class HelloClass
Overloads Shared Sub Main(ByVal args() As String)
Dim name As String = "VB.NET"
If args.Length = 1 Then name = args(0)
Console.WriteLine("Hello, " & name & "!")
End Sub
End Class
End Namespace |
using System;
namespace HelloNamespace {
public class HelloClass{
public static void Main(string[] args) {
string name = "C#";
if (args.Length == 1)
name = args[0];
Console.WriteLine("Hello, " + name + "!");
}
}
} |
|
|
|
|
|
|
|
|
|
|
|
Boolean
Byte, SByte
Char
Short, UShort, Integer, UInteger, Long, ULong
Single, Double
Decimal
Date
Object
String
Dim correct As Boolean = True
Dim b As Byte = &H2A
Dim o As Byte = &O52
Dim person As Object = Nothing
Dim name As String = "Dwight"
Dim grade As Char = "B"c
Dim today As Date = #12/31/2007 12:15:00 PM#
Dim amount As Decimal = 35.99@
Dim gpa As Single = 2.9!
Dim pi As Double = 3.14159265
Dim lTotal As Long = 123456L
Dim sTotal As Short = 123S
Dim usTotal As UShort = 123US
Dim uiTotal As UInteger = 123UI
Dim ulTotal As ULong = 123UL
Dim x As Integer
Console.WriteLine(x.GetType())
Console.WriteLine(GetType(Integer))
Console.WriteLine(TypeName(x))
Dim d As Single = 3.5
Dim i As Integer = CType(d, Integer)
i = CInt(d)
i = Int(d)
|
bool
byte, sbyte
char
short, ushort, int, uint, long, ulong
float, double
decimal
DateTime
object
string
bool correct = true;
byte b = 0x2A;
object person = null;
string name = "Dwight";
char grade = 'B';
DateTime today = DateTime.Parse("12/31/2007 12:15:00");
decimal amount = 35.99m;
float gpa = 2.9f;
double pi = 3.14159265;
long lTotal = 123456L;
short sTotal = 123;
ushort usTotal = 123;
uint uiTotal = 123;
ulong ulTotal = 123;
int x;
Console.WriteLine(x.GetType());
Console.WriteLine(typeof(int));
Console.WriteLine(x.GetType().Name);
float d = 3.5f;
int i = (int)d;
|
|
|
|
|
| Const MAX_STUDENTS As Integer = 25
ReadOnly MIN_DIAMETER As Single = 4.93
|
const int MAX_STUDENTS = 25;
readonly float MIN_DIAMETER = 4.93f;
|
|
|
|
|
Enum Action
Start
[Stop]
Rewind
Forward
End Enum
Enum Status
Flunk = 50
Pass = 70
Excel = 90
End Enum
Dim a As Action = Action.Stop
If a <> Action.Start Then _
Console.WriteLine(a.ToString & " is " & a)
Console.WriteLine(Status.Pass)
Console.WriteLine(Status.Pass.ToString()) |
enum Action {Start, Stop, Rewind, Forward};
enum Status {Flunk = 50, Pass = 70, Excel = 90};
Action a = Action.Stop;
if (a != Action.Start)
Console.WriteLine(a + " is " + (int) a);
Console.WriteLine((int) Status.Pass);
Console.WriteLine(Status.Pass); |
|
|
|
|
|
= < > <= >= <>
+ - * /
Mod
\
^
= += -= *= /= \= ^= <<= >>= &=
And Or Xor Not << >>
AndAlso OrElse And Or Xor Not
Note: AndAlso and OrElse perform short-circuit logical evaluations
&
|
== < > <= >= !=
+ - * /
%
/
Math.Pow(x, y)
= += -= *= /= %= &= |= ^= <<= >>= ++ --
& | ^ ~ << >>
&& || & | ^ !
Note: && and || perform short-circuit logical evaluations
+
|
|
|
|
|
|
greeting = IIf(age < 20, "What's up?", "Hello")
If age < 20 Then greeting = "What's up?"
If age < 20 Then greeting = "What's up?" Else greeting = "Hello"
If x <> 100 And y < 5 Then x *= 5 : y *= 2
If x <> 100 And y < 5 Then
x *= 5
y *= 2
End If
If whenYouHaveAReally < longLine And _
itNeedsToBeBrokenInto2 > Lines Then _
UseTheUnderscore(charToBreakItUp)
If x > 5 Then
x *= y
ElseIf x = 5 Then
x += y
ElseIf x < 10 Then
x -= y
Else
x /= y
End If
Select Case color
Case "pink", "red"
r += 1
Case "blue"
b += 1
Case "green"
g += 1
Case Else
other += 1
End Select
|
greeting = age < 20 ? "What's up?" : "Hello";
if (age < 20)
greeting = "What's up?";
else
greeting = "Hello";
if (x != 100 && y < 5) {
x *= 5;
y *= 2;
}
if (x > 5)
x *= y;
else if (x == 5)
x += y;
else if (x < 10)
x -= y;
else
x /= y;
switch (color) { // Must be integer or string
case "pink":
case "red": r++; break;
case "blue": b++; break;
case "green": g++; break;
default: other++; break;
}
|
|
|
|
|
| |
While c < 10
c += 1
End While |
Do Until c = 10
c += 1
Loop
|
Do While c < 10
c += 1
Loop |
For c = 2 To 10 Step 2
Console.WriteLine(c)
Next
|
| |
Do
c += 1
Loop While c < 10 |
Do
c += 1
Loop Until c = 10 |
Dim names As String() = {"Fred", "Sue", "Barney"}
For Each s As String In names
Console.WriteLine(s)
Next
Dim i As Integer = 0
While (True)
If (i = 5) Then Exit While
i += 1
End While
For i = 0 To 4
If i < 4 Then Continue For
Console.WriteLine(i)
Next
|
while (c < 10)
c++;
for (c = 2; c <= 10; c += 2)
Console.WriteLine(c);
do
c++;
while (c < 10);
string[] names = {"Fred", "Sue", "Barney"};
foreach (string s in names)
Console.WriteLine(s);
int i = 0;
while (true) {
if (i == 5)
break;
i++;
}
for (i = 0; i < 5; i++) {
if (i < 4)
continue;
Console.WriteLine(i);
}
|
|
|
|
|
|
Dim nums() As Integer = {1, 2, 3}
For i As Integer = 0 To nums.Length - 1
Console.WriteLine(nums(i))
Next
Dim names(4) As String
names(0) = "David"
names(5) = "Bobby"
ReDim Preserve names(6)
Dim twoD(rows-1, cols-1) As Single
twoD(2, 0) = 4.5
Dim jagged()() As Integer = { _
New Integer(4) {}, New Integer(1) {}, New Integer(2) {} }
jagged(0)(4) = 5
|
int[] nums = {1, 2, 3};
for (int i = 0; i < nums.Length; i++)
Console.WriteLine(nums[i]);
string[] names = new string[5];
names[0] = "David";
names[5] = "Bobby";
string[] names2 = new string[7];
Array.Copy(names, names2, names.Length);
float[,] twoD = new float[rows, cols];
twoD[2,0] = 4.5f;
int[][] jagged = new int[3][] {
new int[5], new int[2], new int[3] };
jagged[0][4] = 5;
|
|
|
|
|
|
Sub TestFunction(ByVal x As Integer, ByRef y As Integer, ByRef z As Integer)
x += 1
y += 1
z = 5
End Sub
Dim a = 1, b = 1, c As Integer
TestFunction(a, b, c)
Console.WriteLine("{0} {1} {2}", a, b, c)
Function Sum(ByVal ParamArray nums As Integer()) As Integer
Sum = 0
For Each i As Integer In nums
Sum += i
Next
End Function
Dim total As Integer = Sum(4, 3, 2, 1)
Sub SayHello(ByVal name As String, Optional ByVal prefix As String = "")
Console.WriteLine("Greetings, " & prefix & " " & name)
End Sub
SayHello("Strangelove", "Dr.")
SayHello("Madonna")
|
void TestFunction(int x, ref int y, out int z) {
x++;
y++;
z = 5;
}
int a = 1, b = 1, c; // c doesn't need initializing
TestFunction(a, ref b, out c);
Console.WriteLine("{0} {1} {2}", a, b, c);
int Sum(params int[] nums) {
int sum = 0;
foreach (int i in nums)
sum += i;
return sum;
}
int total = Sum(4, 3, 2, 1); // returns 10
void SayHello(string name, string prefix) {
Console.WriteLine("Greetings, " + prefix + " " + name);
}
void SayHello(string name) {
SayHello(name, "");
}
|
|
|
|
|
|
vbCrLf, vbCr, vbLf, vbNewLine
vbNullString
vbTab
vbBack
vbFormFeed
vbVerticalTab
""
Dim school As String = "Harding" & vbTab
school = school & "University"
Dim letter As Char = school.Chars(0)
letter = Convert.ToChar(65)
letter = Chr(65) Dim word() As Char = school.ToCharArray()
Dim msg As String = "File is c:\temp\x.dat"
Dim mascot As String = "Bisons"
If (mascot = "Bisons") Then
If (mascot.Equals("Bisons")) Then
If (mascot.ToUpper().Equals("BISONS")) Then
If (mascot.CompareTo("Bisons") = 0) Then
Console.WriteLine(mascot.Substring(2, 3))
If ("John 3:16" Like "Jo[Hh]? #:*") Then
Imports System.Text.RegularExpressions
Dim r As New Regex("Jo[hH]. \d:*")
If (r.Match("John 3:16").Success) Then
Dim dt As New DateTime(1973, 10, 12)
Dim s As String = "My birthday: " & dt.ToString("MMM dd, yyyy")
Dim buffer As New System.Text.StringBuilder("two ")
buffer.Append("three ")
buffer.Insert(0, "one ")
buffer.Replace("two", "TWO")
Console.WriteLine(buffer)
|
\r
\n
\t
\\
\"
string school = "Harding\t";
school = school + "University";
char letter = school[0];
letter = Convert.ToChar(65);
letter = (char)65; char[] word = school.ToCharArray();
string msg = @"File is c:\temp\x.dat";
string msg = "File is c:\\temp\\x.dat";
string mascot = "Bisons";
if (mascot == "Bisons")
if (mascot.Equals("Bisons"))
if (mascot.ToUpper().Equals("BISONS"))
if (mascot.CompareTo("Bisons") == 0)
Console.WriteLine(mascot.Substring(2, 3));
using System.Text.RegularExpressions;
Regex r = new Regex(@"Jo[hH]. \d:*");
if (r.Match("John 3:16").Success)
DateTime dt = new DateTime(1973, 10, 12);
string s = "My birthday: " + dt.ToString("MMM dd, yyyy");
System.Text.StringBuilder buffer = new System.Text.StringBuilder("two ");
buffer.Append("three ");
buffer.Insert(0, "one ");
buffer.Replace("two", "TWO");
Console.WriteLine(buffer);
|
|
|
|
|
|
Dim ex As New Exception("Something is really wrong.")
Throw ex
Try
y = 0
x = 10 / y
Catch ex As Exception When y = 0
Console.WriteLine(ex.Message)
Finally
Beep()
End Try
On Error GoTo MyErrorHandler
...
MyErrorHandler: Console.WriteLine(Err.Description)
|
Exception up = new Exception("Something is really wrong.");
throw up;
try {
y = 0;
x = 10 / y;
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
finally {
Microsoft.VisualBasic.Interaction.Beep();
}
|
|
|
|
|
|
Namespace MyCompany.Product
...
End Namespace
Namespace MyCompany
Namespace Product
...
End Namespace
End Namespace
Imports MyCompany.Product
|
namespace MyCompany.Product {
...
}
namespace MyCompany{
namespace Product {
...
}
}
using MyCompany.Product;
|
|
|
|
|
|
Public
Private
Friend
Protected
Protected Friend
Shared
Class Game
Inherits Competition
...
End Class
Interface IAlarmClock
...
End Interface
Interface IAlarmClock
Inherits IClock
...
End Interface
Class WristWatch
Implements IAlarmClock, ITimer
...
End Class
|
public
private
internal
protected
protected internal
static
class Game : Competition {
...
}
interface IAlarmClock {
...
}
interface IAlarmClock : IClock {
...
}
class WristWatch : IAlarmClock, ITimer {
...
}
|
|
|
|
|
Class SuperHero
Private _powerLevel As Integer
Public Sub New()
_powerLevel = 0
End Sub
Public Sub New(ByVal powerLevel As Integer)
Me._powerLevel = powerLevel
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class |
class SuperHero {
private int _powerLevel;
public SuperHero() {
_powerLevel = 0;
}
public SuperHero(int powerLevel) {
this._powerLevel= powerLevel;
}
~SuperHero() {
}
}
|
|
|
|
|
|
Dim hero As SuperHero = New SuperHero
Dim hero As New SuperHero
With hero
.Name = "SpamMan"
.PowerLevel = 3
End With
hero.Defend("Laura Jones")
hero.Rest()
SuperHero.Rest()
Dim hero2 As SuperHero = hero
hero2.Name = "WormWoman"
Console.WriteLine(hero.Name)
hero = Nothing
If hero Is Nothing Then _
hero = New SuperHero
Dim obj As Object = New SuperHero
If TypeOf obj Is SuperHero Then _
Console.WriteLine("Is a SuperHero object.")
Using reader As StreamReader = File.OpenText("test.txt")
Dim line As String = reader.ReadLine()
While Not line Is Nothing
Console.WriteLine(line)
line = reader.ReadLine()
End While
End Using
|
SuperHero hero = new SuperHero();
hero.Name = "SpamMan";
hero.PowerLevel = 3;
hero.Defend("Laura Jones");
SuperHero.Rest();
SuperHero hero2 = hero;
hero2.Name = "WormWoman";
Console.WriteLine(hero.Name);
hero = null ;
if (hero == null)
hero = new SuperHero();
Object obj = new SuperHero();
if (obj is SuperHero)
Console.WriteLine("Is a SuperHero object.");
using (StreamReader reader = File.OpenText("test.txt")) {
string line;
while ((line = reader.ReadLine()) != null)
Console.WriteLine(line);
} |
|
|
|
|
|
Structure StudentRecord
Public name As String
Public gpa As Single
Public Sub New(ByVal name As String, ByVal gpa As Single)
Me.name = name
Me.gpa = gpa
End Sub
End Structure
Dim stu As StudentRecord = New StudentRecord("Bob", 3.5)
Dim stu2 As StudentRecord = stu
stu2.name = "Sue"
Console.WriteLine(stu.name)
Console.WriteLine(stu2.name)
|
struct StudentRecord {
public string name;
public float gpa;
public StudentRecord(string name, float gpa) {
this.name = name;
this.gpa = gpa;
}
}
StudentRecord stu = new StudentRecord("Bob", 3.5f);
StudentRecord stu2 = stu;
stu2.name = "Sue";
Console.WriteLine(stu.name);
Console.WriteLine(stu2.name);
|
|
|
|
|
|
Private _size As Integer
Public Property Size() As Integer
Get
Return _size
End Get
Set (ByVal Value As Integer)
If Value < 0 Then
_size = 0
Else
_size = Value
End If
End Set
End Property
foo.Size += 1
|
private int _size;
public int Size {
get {
return _size;
}
set {
if (value < 0)
_size = 0;
else
_size = value;
}
}
foo.Size++;
|
|
|
|
|
|
Delegate Sub MsgArrivedEventHandler(ByVal message As String)
Event MsgArrivedEvent As MsgArrivedEventHandler
Event MsgArrivedEvent(ByVal message As String)
AddHandler MsgArrivedEvent, AddressOf My_MsgArrivedCallback
RaiseEvent MsgArrivedEvent("Test message")
RemoveHandler MsgArrivedEvent, AddressOf My_MsgArrivedCallback
Imports System.Windows.Forms
Dim WithEvents MyButton As Button
MyButton = New Button
Private Sub MyButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyButton.Click
MessageBox.Show(Me, "Button was clicked", "Info", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
|
delegate void MsgArrivedEventHandler(string message);
event MsgArrivedEventHandler MsgArrivedEvent;
MsgArrivedEvent += new MsgArrivedEventHandler(My_MsgArrivedEventCallback);
MsgArrivedEvent("Test message");
MsgArrivedEvent -= new MsgArrivedEventHandler(My_MsgArrivedEventCallback);
using System.Windows.Forms;
Button MyButton = new Button();
MyButton.Click += new System.EventHandler(MyButton_Click);
private void MyButton_Click(object sender, System.EventArgs e) {
MessageBox.Show(this, "Button was clicked", "Info",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
|
|
|
|
|
|
Console.Write("What's your name? ")
Dim name As String = Console.ReadLine()
Console.Write("How old are you? ")
Dim age As Integer = Val(Console.ReadLine())
Console.WriteLine("{0} is {1} years old.", name, age)
Console.WriteLine(name & " is " & age & " years old.")
Dim c As Integer
c = Console.Read()
Console.WriteLine(c)
|
Console.Write("What's your name? ");
string name = Console.ReadLine();
Console.Write("How old are you? ");
int age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0} is {1} years old.", name, age);
Console.WriteLine(name + " is " + age + " years old.");
int c = Console.Read();
Console.WriteLine(c);
|
|
|
|
|
|
Imports System.IO
Dim writer As StreamWriter = File.CreateText("c:\myfile.txt")
writer.WriteLine("Out to file.")
writer.Close()
Dim reader As StreamReader = File.OpenText("c:\myfile.txt")
Dim line As String = reader.ReadLine()
While Not line Is Nothing
Console.WriteLine(line)
line = reader.ReadLine()
End While
reader.Close()
Dim str As String = "Text data"
Dim num As Integer = 123
Dim binWriter As New BinaryWriter(File.OpenWrite("c:\myfile.dat"))
binWriter.Write(str)
binWriter.Write(num)
binWriter.Close()
Dim binReader As New BinaryReader(File.OpenRead("c:\myfile.dat"))
str = binReader.ReadString()
num = binReader.ReadInt32()
binReader.Close()
|
using System.IO;
StreamWriter writer = File.CreateText("c:\\myfile.txt");
writer.WriteLine("Out to file.");
writer.Close();
StreamReader reader = File.OpenText("c:\\myfile.txt");
string line = reader.ReadLine();
while (line != null) {
Console.WriteLine(line);
line = reader.ReadLine();
}
reader.Close();
string str = "Text data";
int num = 123;
BinaryWriter binWriter = new BinaryWriter(File.OpenWrite("c:\\myfile.dat"));
binWriter.Write(str);
binWriter.Write(num);
binWriter.Close();
BinaryReader binReader = new BinaryReader(File.OpenRead("c:\\myfile.dat"));
str = binReader.ReadString();
num = binReader.ReadInt32();
binReader.Close();
|
|
Source: http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
|
Thursday, December 27, 2007
ASP.NET textbox multiline maxlength
multiline textbox with maxlength in asp.net
According to msdn in ASP.NET you can not use textbox’s MaxLength property with Multiline Mode. But I was required in my current application. So I search google and other search engines and finally got few solution. I am simply compiling all of the solutions in single post.
Solution Number 1 for
ASP.NET TextBox.MultiLine maxlength
Add following javascript
function Count(text,long)
{
var maxlength = new Number(long); // Change number to your max length.
if(document.getElementById('<%=textBox.ClientID%>').value.length > maxlength){
text.value = text.value.substring(0,maxlength);
alert(" Only " + long + " chars");
}
Where “textBox” is the asp text box ID.
Also add following events in your textbox.
onKeyUp="javascript:Count(this,200);" onChange="javascript:Count(this,200);"
Your textbox code should look like
<asp:TextBox ID="textBox" onKeyUp="javascript:Count(this,2);" onChange="javascript:Count(this,2);" TextMode=MultiLine Columns="5" Rows="5" runat=server>
</asp:TextBox>
Solution Number 2 for
ASP.NET TextBox.MultiLine maxlength
Another way to achieve this is regular expression. You can add following regular expression validate on asp text box.
<asp:RegularExpressionValidator ID="txtConclusionValidator1" ControlToValidate="textBox" Text="Exceeding 200 characters" ValidationExpression="^[\s\S]{0,2}$" runat="server" />
Hope this helps you!!!
Mutex Could not be Created.
Some time while running ASP.NET web application through Visual Studio you might receive following error
Server Error in Application. Mutex could not be created.
Few workaround for
“Mutex Could not be Created.”
“Mutex Could not be Created.”
Solution number 1
1. If your visual studio 2005 is open, closed it.
2. Go to the ASP.NET temporary folder for v2.0 of the framework
\Microsoft.Net\Framework\v2.0
\Temporary ASpNET pages 3. Remove the folder for your application
4. Reset IIS (iisreset)
5. First Browse your page from Browser
6. Re-open Visual studio
<
“Mutex Could not be Created.”
Solution number 2
1. locate the current machine config file (e.g at C:\WINNT\Microsoft.NET\Framework\v2.0.50727\CONFIG\)
2. update the Machine.Config under the
tag like that -
“Mutex Could not be Created.”
Solution number 3
Cause: This occurs because the permissions on the following registry key no longer have your custom account:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\CompilationMutexName
The compilation mutex gets it's permissions from this registry key and with your custom account missing, the process running ASP.NET cannot get a handle to the mutex and fails during compilation.
Resolution:
=========
1. Run the following to add your custom account to the registry key permissions:
ASPNET_regiis -ga domain\account.
2. Either restart the server or close the handles to the mutex (see below)
To close the handles to the Mutex:
3. Download and launch Process Explorer from www.sysinternals.com
4. From the Find menu, select Find Handle or DLL
5. In the Handle or DLL substring box, type “mutant” (without quotes) and click Search
6. Click the Handle or DLL column heading to sort the items and find a mutex that starts with CL. The handle will typically be devenv.exe (the IDE for Visual Studio) and aspnet_wp.exe or w3wp.exe. The handle will look similar to:
7. \BaseNameObjects\CLbdd6aa8f
8. Select the handle in the search box and Process Explorer locates the Process and the handle in the main window
9. Right-click the handle in the main window and select Close Handle
Additional Info:
============
The error may occur anytime you run ASP.NET as a custom account and the above mentioned registry key does not have the account listed in the permissions.
If you receive the error and you are running with a custom account on IIS 6 in worker process mode (code running in w3wp.exe), you can add your custom account to the IIS_WPG group on the server. The IIS_WPG group is granted access to the registry key by default.
“Mutex Could not be Created.”
Solution Number 4
You may also need to fix the perimssions manually, as follows:
1. Run Registry Editor 32: Windows -> Run -> "REGEDT32"
2. Locate the sub-window "HKEY_LOCAL_MACHINE on Local Machine"
3. Navigate to the key:
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\"
(and select it).
4. Click the menu "Security" then "Permissions".
5. Ensure the custom account you are using to run aspnet (e.g. "mydomain\aspnet") is in this permissions list.
If it is not then Add it and ensure "Full Control" is ticked, then click OK.
6. This should immediately resolve the Mutex locking issue (just refresh your page, or rebuild in Visual Studio).
7. If not then do an IISRESET first then retry step 6.
“Mutex Could not be Created.”
Solution number 5
Go to the Visual Studio Command Prompt and reach at
c:\Windows\Microsoft.net\Framework\v2.0.50727>
and type the command
c:\Windows\Microsoft.net\Framework\v2.0.50727> aspnet_regiis -ga Domain\User
After that, go to the windows\microsoft.net\framework\v2.0.50727 and there you'll get a temporary file. Just delete it without any hasitation. Rfresh and restart the IIS.
“Mutex Could not be Created.”
Solution number 6 On Vista Business 1. Delete my app from the aspnet folder
2. Opened Regedit. Went to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.050727.0. Right clicked and added aspnet as user providing it full-control permissions.
Hope this help!!!....
Wednesday, December 26, 2007
Items collection cannot be modified when the DataSource property is set.
This exception
“Items collection cannot be modified when the DataSource property is set.”
occurs when you trying to add some text like “Select” or “None” in combo box (drop down list) in .NET framework window form control. There is no such way to add items in combo box’s items property after you set DataSource. To avoid this you can add one more item in your datasource. For example if you are trying to bind drop down list through DataSet then add one more row into DataSet. There is one more workaround for
“Items collection cannot be modified when the DataSource property is set.”
If you like? http://www.codeproject.com/KB/combobox/UnboundItemsComboBox.aspx Hope this will help you to solve the exception
“Items collection cannot be modified when the DataSource property is set.”
Tuesday, December 25, 2007
Sunday, December 23, 2007
Wednesday, August 08, 2007
Friday, July 27, 2007
Hi
Today
http://www.thinkinterview.com launched.
Thanks
Mahesh
Thursday, April 19, 2007
Hi,
I am going to start quiz on BizTalk.
In first part I am putting question related to Schema.
You can answer these questions in comment section and letter on I’ll update this blog entry with the appropriate answer with the name of sender.
So let’s start the knowledge train…
- What is BizTalk?
- How can you reuse existing schema?
- What is properties promotion?
- Type of properties promotion.
- Instance Specific properties VS System or Exchange Specific Properties.
- What is Envelop?
- What is Message Type in BizTalk?
- Promoted Properties VS Distinguished Fields.
- “MessageContextPropertiesBase” vs “MessageDataPropertiesBase”.
- How to access Promoted Properties and Distinguished Fields?
Thanks
Mahesh
ASP.NET Interview Questions |
C# Interview Questions |
.NET Interview Questions |
Dot Net Interview Questions |
VB.NET Interview Questions |
Oracle Interview Questions
Wednesday, July 05, 2006
Introduction:
There are lost of discussion on the internet about the Interface vs Abstract class. Also, as base class whether we have to use interface, abstract class or normal class.
I am trying to point out few considerations on which we can take decision about Interface vs Abstract class vs Class.
Abstract Class vs Interface
I am assuming you are having all the basic knowledge of abstract and interface keyword. I am just briefing the basics.
We can not make instance of Abstract Class as well as Interface.
Here are few differences in Abstract class and Interface as per the definition.
Abstract class can contain abstract methods, abstract property as well as other members (just like normal class).
Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract.
//Abstarct Class
public abstract class Vehicles
{
private int noOfWheel;
private string color;
public abstract string Engine
{
get;
set;
}
public abstract void Accelerator();
}
//Interface
public interface Vehicles
{
string Engine
{
get;
set;
}
void Accelerator();
}
We can see abstract class contains private members also we can put some methods with implementation also. But in case of interface only methods and properties allowed.
We use abstract class and Interface for the base class in our application.
This is all about the language defination. Now million doller question:
How can we take decision about when we have to use Interface and when Abstract Class.
Basicly abstact class is a abstract view of any realword entity and interface is more abstract one. When we thinking about the entity there are two things one is intention and one is implemntation. Intention means I know about the entity and also may have idea about its state as well as behaviour but don’t know about how its looks or works or may know partially. Implementation means actual state and behaviour of entity.
Enough theory lets take an example.
I am trying to make a Content Management System where content is a genralize form of article, reviews, blogs etc.
So content is our base class now how we make a decision whether content class should be Abstract class, Interface or normal class.
First normal class vs other type (abstract and interface). If content is not a core entity of my application means as per the business logic if content is nothing in my application only Article, Blogs, Review are the core part of business logic then content class should not be a normal class because I’ll never make instance of that class. So if you will never make instance of base class then Abstract class and Interface are the more appropriate choice.
Second between Interface and Abstract Class.
As you can see content having behavior named “Publish”. If according to my business logic Publish having some default behavior which apply to all I’ll prefer content class as an Abstract class. If there is no default behavior for the “Publish” and every drive class makes their own implementation then there is no need to implement “Publish” behavior in the base case I’ll prefer Interface.
These are the in general idea of taking decision between abstract class, interface and normal class. But there is one catch. As we all know there is one constant in software that is “CHANGE”. If I made content class as Interface then it is difficult to make changes in base class because if I add new method or property in content interface then I have to implement new method in every drive class. These problems will over come if you are using abstract class for content class and new method is not an abstract type. So we can replace interface with abstract class except multiple inheritance.
CAN-DO and IS-A relationship is also define the deference between Interface and abstract class. As we already discuss Interface can be use for multiple inheritance for example we have another interface named “ICopy” which having behavior copy and every drive class have to implements its own implementation of Copy. If “Article” class drive from abstract class Content as well as ICopy then article “CAN-DO” copy also.
IS-A is for “generalization” and “specialization” means content is a generalize form of Article, Blogs, Review and Article, Blogs, Review are a specialize form of Content.
So, abstract class defines core identity. If we are thinking in term of speed then abstract is fast then interface because interface requires extra in-direction.
So as per my view Abstract class having upper-hand in compare to interface. Using interface having only advantage of multiple inheritance. If you don’t understand the things then don’t worry because it’s my mistake because I am not able to describe the topic.
suggested reading:
MORE POST
Thursday, November 30, 2006
Windows PowerShell is a new shell scripting interface built on the Microsoft .NET framework that enables IT Pros and .NET developers to control and automate the administration of Windows and applications. It uses a new admin-focused scripting language and features more than 130 standard command-line tools.
Download Windows PowerShell 1.0
Getting Started Guide and Quick Reference sheet
PowerShell blog
Cheers!!!
Mahesh
ASP.NET Interview Questions |
C# Interview Questions |
.NET Interview Questions |
Dot Net Interview Questions |
VB.NET Interview Questions |
Oracle Interview Questions
Friday, November 24, 2006
It took Italians to make this one!
Pls click the link below to see the video.
Superb Advertisement- shows popularity and respect to Gandhiji,
A great ad.... Ironically from a non- Indian company!!
And none the less This ad won the EPICA awards for best ad.
http://www.epica-awards.org/assets/epica/2004/winners/film/flv/11071.htm
Cheers!!!
Mahesh
ASP.NET Interview Questions |
C# Interview Questions |
.NET Interview Questions |
Dot Net Interview Questions |
VB.NET Interview Questions |
Oracle Interview Questions
Thursday, November 23, 2006
Metcalfe law is one of the fundamental laws of information technology. He explains his law with the example of Fax machine. He explained: there is no use of single or un-connected fax machine. When fax machine connected with other fax machine its values grows is about squire proportional to the no of connection.
http://en.wikipedia.org/wiki/Metcalfe's_law
Cheers!!!
Mahesh
ASP.NET Interview Questions |
C# Interview Questions |
.NET Interview Questions |
Dot Net Interview Questions |
VB.NET Interview Questions |
Oracle Interview Questions
Monday, October 09, 2006
.NET having solution files, project files and web project.
Solution file can contains multiple project files as well as web project.
Few days back I had to start building new .NET based application. I found few good things and try to share.
First of all I am having multiple projects in the solution.
Logical layers for my web application are:
(user) -> UI -> [AL -> BLL -> DAL] -> (DB)
[ -> DTOs ]
[ -> ES ]
- UI = User interface
- AL = Application layer (handlers, as web pages and web services)
- BLL = Business logic layer (business logic + domain objects)
- DAL = Data access layer (wrap DB and map data to entities and back)
- DTOs = Data transfer objects (Mapped to DB entity) referenced by BL and DAL.
- ES = External services
Cheers
Mahesh
maheshsingh21@hotmail.com