VB.Net:
fbnfgndf
To keep this list as a list and prevent it becomming too much of a debate could any discussions regarding it's content be posted at http://www.xtremedotnettalk.com/showthread.php?t=97091, Thanks PD.
The differences between C# and VB have been growing smaller and smaller with each .Net release to the point where translating between them is mostly a trivial task. Despite this, newcomers to VB.Net are overwhelmed and confused by the mass of curly braces, semicolons, and strange compiler errors when copying and pasting code. The truth is that when it comes to the .Net Framework, C# and VB.Net are almost identical but there still are some major differences in syntax that can be very confusing.
I'll start with some of the basics. Please feel free to add to this list. The point is not to have an exhaustive list of conversion recipes, but to bring together enough information so that a newcomer to VB with no C# knowledge can read C#.
If you see a mistake, PM the person who wrote it so they can fix it.
Comments
C#:
//this is a one line comment
/* this is a
multi-line comment */
///<summary>This is an XML comment</summary>
VB.Net:
' this is a single line comment
'''<summary>This is an XML comment</summary>
Declaring Variables
C#:
int maxValue = 45;
MyClass super = new MyClass();
VB.Net:
Dim maxValue as Integer = 45
Dim super1 as new MyClass
Dim super2 as MyClass = new MyClass
void functions/subs -- methods that do not return a value
Code:
[CODE=vbnet]Public Sub SuperFunction()
'...
End Sub
Methods that return a value
C#:
public string SuperFunction()
{
//...
}
public int AnotherSuperFunction()
{
//...
}
VB.Net:
Public Function SuperFunction() As String
'...
End Function
'
Public Function AnotherSuperFunction() As Integer
'...
End Function
Last edited by a moderator: