Some developers assume that many things that are possible in Visual C# .NET are impossible in Visual Basic .NET but this assumption is incorrect. Both Visual Basic.Net and Visual C#.net are the part of .net framework and have no performance issues between them. So the question in the mind arises that which language we choose among these two. So the answer is the choice between Visual Basic .NET and Visual C# .NET is typically based on your personal preference and past experience; for example, it is easier for Visual Basic 6.0 developers to use Visual Basic .NET, and for Visual C++ and Java programmers to use Visual C# .NET.
Syntactically difference between two languages are:
Syntactically difference between two languages are:
1) Variable declaration and assignment
2) Data Types
3) Operators
4) Conditional Statements
5) Loop Statements
6) Use of Arrays
7) Keywords
1) Variable declaration and assignment
Visual Basic.Net | Visual C#.Net |
---|---|
Dim num1 As Integer | int num1=10; |
2) Data Types
Visual Basic.Net | Visual C#.Net | .Net Framework |
---|---|---|
Byte | byte | System.Byte |
Short | short | System.Int16 |
Integer | int | System.Int32 |
Long | long | System.Int64 |
Single | float | System.Single |
Double | double | System.Double |
Decimal | decimal | System.Decimal |
Date | DateTime | System.DateTime |
Boolean | bool | System.Boolean |
String | string | System.String |
Char | char | System.Char |
Object | object | System.Object |
n/a | sbyte | System.Sbyte |
n/a | ushort | System.UInt16 |
n/a | uint | System.UInt32 |
n/a | ulong | System.UInt64 |
3) Operators
Operator | Visual Basic.Net | Visual C#.Net |
---|---|---|
Modulus | Mod | % |
Exponentiation | ^ | n/a |
Compare two object | Is | == |
Compare strings | = | == |
Concatenate strings | & | + |
Logical And | And | && |
Logical Or | Or | || |
Left shift | n/a | < |
Right shift | n/a | >> |
Increment | n/a | ++ |
Decrement | n/a | -- |
Logical Not | Not | ! |
4) Conditonal Statements
Visual Basic.Net | Visual C#.Net |
---|---|
If num1>num2 Then Console.WriteLine("num1 is greater") Else Console.WriteLine("num2 is greater") End If | if(num1>num2) { Console.WriteLine("num1 is greater") } else { Console.WriteLine("num2 is greater") } |
5) Loop Statements
Loop | Visual Basic.Net | Visual C#.Net |
---|---|---|
While | Dim i As Integer =1 While(i<11) Console.WriteLine(i) i=i+1 End While | int num1=1; while(i<11) { Console.WriteLine(i); i++; } |
Do While | Dim i As Integer =1 Do Console.WriteLine(i) i=i+1 Loop While(i<11) | int num1=1; do { Console.WriteLine(i); i++; } while(i<11); |
For | Dim i As Integer For i=1 to 10 Console.WriteLine(i) Next | int num1; for(i=1;i<=10;i++) { Console.WriteLine(i); } |
Use of Arrays
Visual Basic.Net | Visual C#.Net |
---|---|
Dim array1() As Integer={9,8,7,6} | int[] array1={9,8,7,6} ; |
No comments:
Post a Comment