Monday, March 28, 2011

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?

Thanks in advance,

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

  • I think you will find the answers to your question in this articles:

    http://en.wikipedia.org/wiki/Comparison_of_C_sharp_and_Visual_Basic_.NET

    and

    http://geekswithblogs.net/jmccarthy/archive/2007/01/23/104372.aspx

    edit: Noldorin was faster :x

  • The first thing to know about learning C# is that it is not pronounced "C#.net", it is just C#. Microsoft tacked on ".NET" to VB, because there was a previous version of VB that didn't work on the .NET Framework. C# was created specifically with the .NET Framework in mind, so the ".net" is implied and unnecessary. Also as a side note putting "C#.NET" on your resume really tips off a knowledgeable manager to your skill level, or lack there of, regarding C#.

    Also this Wikipedia article is really good for showing the pros and cons as well as the differences between C# and VB.NET at a high level.

    Niyaz : Thanks for the resume tip!!!!
  • Follow following links which give detailed differences

    http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

    http://www.codeproject.com/KB/dotnet/vbnet_c__difference.aspx

    http://support.microsoft.com/kb/308470

    In spite of differences as mentioned at http://support.microsoft.com/kb/308470 both C# and VB.Net are first class citizens of .Net world

    Although there are differences between Visual Basic .NET and Visual C# .NET, both are first-class programming languages that are based on the Microsoft .NET Framework, and they are equally powerful. Visual Basic .NET is a true object-oriented programming language that includes new and improved features such as inheritance, polymorphism, interfaces, and overloading. Both Visual Basic .NET and Visual C# .NET use the common language runtime. There are almost no performance issues between Visual Basic .NET and Visual C# .NET. Visual C# .NET may have a few more "power" features such as handling unmanaged code, and Visual Basic .NET may be skewed a little toward ease of use by providing features such as late binding. However, the differences between Visual Basic .NET and Visual C# .NET are very small compared to what they were in earlier versions.

  • 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.

0 comments:

Post a Comment