views:

920

answers:

12

Certainly there's the difference in general syntax, but what other critical distinctions exist? There are some differences, right?

+6  A: 

This topic has had a lot of face time since .Net 2.0 was released. See this Wikipedia article for a readable summary.

Rob Allen
A: 

This is a very comprehensive reference.

Tom Grochowicz
+2  A: 

Since I assume you can google, I don't think a link to more sites is what you are looking for.

My answer: Choose base on the history of your developers. C# is more JAVA like, and probably C++ like. VB.NET was easier for VB programmers, but I guess that is no really an issue anymore sine there are no new .NET programmers coming from old VB.

My opinion is that VB is more productive then C#, it seems it is always ahead in terms of productivity tools (such as intelisense), and I would recommend vb over c# to someone that asks. Of course, someone that knows he prefers c# won't ask, and c# is probably the right choice for him.

csmba
You assume a lot ;)
Ant
+16  A: 

The linked comparisons are very thorough, but as far as the main differences I would note the following:

  • C# has anonymous methodsVB has these now, too
  • C# has the yield keyword (iterator blocks)
  • VB supports implicit late binding
  • VB supports XML literals
  • VB is case insensitive
  • More out-of-the-box code snippets for VB
  • More out-of-the-box refactoring tools for C#

In general the things MS focuses on for each vary, because the two languages are targeted at very different audiences. This blog post has a good summary of the target audiences. It is probably a good idea to determine which audience you are in, because it will determine what kind of tools you'll get from Microsoft.

Luke
VB has anonymous functions, just so long as they return a value.There is no such thing as an anonymous method. A method, by definition, is a named function that implicitly takes an object reference.
Jonathan Allen
VB does not have the yield keyword which C# supports
Yogendra
C# now also supports a form of late binding, through the `dynamic` keyword. This is still different from VB.Net: in VB you allow binding by turning 'Option Strict' on or off either at the project level or at the file level. In C#, the late binding support is more explicit (at the statement level), through the use of the `dynamic` keyword.
jeroenh
A: 

Apart from syntax not that much any more. They both compile to exactly the same IL, so you can compile something as VB and reflect it into C#.

Most of the apparent differences are syntactic sugar. For instance VB appears to support dynamic types, but really they're just as static as C#'s - the VB compiler figures them out.

Visual Studio behaves differently with VB than with C# - it hides lots of functionality but adds background compiling (great for small projects, resource hogging for large ones) and better snippet support.

With more and more compiler 'magic' in C#3 VB.Net has really fallen behind. The only thing VB now has that C# doesn't is the handles keyword - and that's of debatable benefit.

@Tom - that really useful, but a little out of date - VB.Net now supports XML docs too with '''

@Luke - VB.Net still doesn't have anon-methods, but does now support lambdas.

Keith
You totally forget VB's XML support.
Jonathan Allen
Ahh, yes, of course. VB supports inline XML - I'm still not sure of the benefit of mixing data and code like that.
Keith
+2  A: 

This may be considered syntax, but VB.NET is case insensitive while C# is case sensitive.

Terrapin
I don't consider this a feature...
Michael Haren
Oh it's a feature allright. Go ahead, try debugging a pile of code where you have intcounter and intCounter being two different variables. There should be NO difference between the two. Case sensitivity is a leftover from days when computing power was far more expensive (and parsing a line where "A" <> "a" is quicker than figuring out they're really the same).
David
A: 

When it gets to IL its all just bits. That case insensitivity is just a precompiler pass. But the general consensus is, vb is more verbose. If you can write c# why not save your eyes and hands and write the smaller amount of code to do the same thing.

DevelopingChris
+2  A: 

Although the syntax sugar on C#3 has really pushed the bar forward, I must say some of the Linq to XML stuff in VB.Net seems quite nice and makes handling complex, deeply nested XML a little bit more tolerable. Just a little bit.

+1  A: 

One glaring difference is in how they handle extension methods (Vb.Net actually allows something that C# doesn't - passing the type on which the extension method is being defined as ref): http://blog.gadodia.net/extension-methods-in-vbnet-and-c/

Vaibhav
A: 

Scott Hanselman recently wrote an interesting article contrasting var and Dim: Back to Basics: var != Dim

Adam Lassek
A: 

VB has its VB-cry baby Option Strict = Off|On setting; C# only does it the right way.

rp
The right way? C# has its own lame-ass settings like defaulting to not checking for integer overlfows.
Jonathan Allen
@Jonathan--I was surprised that VB and C# have different over/under flow defaults, too...
Michael Haren
A: 

The biggest difference in my opinion is the ability to write unsafe code in C#.

the_lotus