What are the differences between C#.net and Visual Basic.net?


I have a small experience in VB.net and I would like to learn C#.net

What are the differences between VB.net and C#.net?

Is there any difference in performance between these two?

Apart from the syntactical differences, are there any major changes that I have to keep in mind?

12/2/2015 7:04:01 PM

Accepted Answer

The Language Features section of the Wikipedia article offers a good overview. Performance is essentially equivalent in almost every aspect, from what I understand.

2/7/2009 1:16:34 PM

Performance is equivalent if you write equivalent code, but VB.NET has constructs that are in there for "backward compatibility" which should NEVER be used. C# doesn't have some of these things. I'm thinking specifically of:

  • Functions which are in the Microsoft.VisualBasic namespace which are members of other standard .NET classes like Trim(). The .NET classes are often faster.

  • Redim and Redim Preserve. Never to be used in .NET, but there they are in VB.

  • On Error ... instead of exceptions. Yuck!

  • Late binding (sometimes derisively called "Option Slow"). Not a good idea in a non-dynamic .NET language from a performance perspective.

VB is also missing things like automatic properties which makes it pretty undesirable for me. Not a performance issue, but worth keeping in mind.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow