Best Industrial Training in C,C++,PHP,Dot Net,Java in Jalandhar

Sunday 22 December 2013

Difference between vb.net and c#.net


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:

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.NetVisual C#.Net
Dim num1 As Integerint num1=10;

2) Data Types


Visual Basic.NetVisual C#.Net.Net Framework
BytebyteSystem.Byte
ShortshortSystem.Int16
IntegerintSystem.Int32
LonglongSystem.Int64
SinglefloatSystem.Single
DoubledoubleSystem.Double
DecimaldecimalSystem.Decimal
DateDateTimeSystem.DateTime
BooleanboolSystem.Boolean
StringstringSystem.String
CharcharSystem.Char
ObjectobjectSystem.Object
n/asbyteSystem.Sbyte
n/aushortSystem.UInt16
n/auintSystem.UInt32
n/aulongSystem.UInt64

3) Operators


OperatorVisual Basic.NetVisual C#.Net
ModulusMod%
Exponentiation^n/a
Compare two objectIs==
Compare strings===
Concatenate strings&+
Logical AndAnd&&
Logical OrOr||
Left shiftn/a<
Right shiftn/a>>
Incrementn/a++
Decrementn/a--
Logical NotNot!

4) Conditonal Statements


Visual Basic.NetVisual 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


LoopVisual Basic.NetVisual C#.Net
WhileDim 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 WhileDim 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);
ForDim 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.NetVisual C#.Net
Dim array1() As Integer={9,8,7,6}int[] array1={9,8,7,6} ;

No comments:

Post a Comment