locked
C# or VB.NET RRS feed

  • Question

  • I know VB language, and I am comfortable with the C++ style too. But now I need to learn some .NET compatible language. Which language would you recommend, C# or VB.NET? I know the little aspects, like C# is case-sensitive and VB.NET doesn't has pointers but references. But I've heard people recommend C# more, over VB.NET. Anyone knows some good reason for it?
    Monday, April 4, 2011 9:43 AM

Answers

  • Hi,

    Short and simple answer, pick the one you like best.  And change after a while if you then decide you like the other better.  Or learn both equally well.  C# and VB.Net are equally good, and once you know one you will at least be able to follow code written in the other.  You are basically learning .Net.  What the syntax is doesn't matter much.

    Microsoft makes a point of demonstrating they focus equally much on both languages and will do code demonstration in random languages.  Anders Hejlsberg placed the C# vs the VB choice as a matter of history.  Most likely job opportunities dictate which language you will end up using, but it is easy to switch language.

    One point though.  Do not decide based on a single features. If you need it, you can always create a separate assembly using that specific feature.


    ---
    Happy Coding!
    Morten Wennevik [C# MVP]
    • Proposed as answer by Cor Ligthert Tuesday, April 5, 2011 8:07 AM
    • Marked as answer by prateek203 Tuesday, April 5, 2011 6:49 PM
    Tuesday, April 5, 2011 5:41 AM

All replies

  • Hello prateek203,

     

    as far as i know, C# is 100% optimized for Dot-Net. I had read that C# (C-Sharp) has been build for .NET (Dot-Net).

    But VB.NET works with .Net (Dot-Net) fine (my trainer told me). I would personel recommend to learn as many programming lang. as possible (if you have the time).

     

    Regards


    S.A., VS 2008 C Sharp beginner
    Monday, April 4, 2011 9:57 AM
  • Ummm, actually it's not that I need to "learn" these languages. I can work with them both, as Visual Studio IDE makes it really simple now. But I'm kinda confused which one should I go with. And why are C# programmers paid more in jobs, than VB.NET (if it's true)?
    • Edited by prateek203 Thursday, May 10, 2012 9:39 AM
    Monday, April 4, 2011 10:18 AM
  • Now and again this question is asked and it always ends up the same; a small flame war.

     

    Do a search on the forum and see what I mean. Don't want to appear rude but this question is getting old.




    "The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination." - Fred Brooks
    • Proposed as answer by Cor Ligthert Tuesday, April 5, 2011 8:08 AM
    Monday, April 4, 2011 10:49 AM
  • Dear Prateek203,

     

    As far as my knowledge goes I'll recommend C#.NET. The reason for saying is few months before I've work in VB.NET with Framework 2.0.  I've noticed one thing in VB.NET but not in C#.NET. Try below code in both

     

    1. Create new instance to GUID class like

    Dim objVB as NEW Guid("{dddddddd-dddd-dddd-dddd-dddddddddddd} ")
    
    & 
    
    GUID ObjCS = New Guid("{dddddddd-dddd-dddd-dddd-dddddddddddd} ")
    
    

     

    Even though if we assign default guid string in contructor objVB having null reference, but not in C#.NET. So I'm using C#.NET now.


    Thanks and Regards, Bharath S.
    Monday, April 4, 2011 12:05 PM
  • Bharath S,

    If you used proper syntax in vb.net, the value wouldn't be null:

    dim objVB as GUID = New Guid("{dddddddd-dddd-dddd-dddd-dddddddddddd} ")

    Prateek,

    Derek is correct. This question has been asked more times than it should. The answer is, "it doesn't matter. Pick one."

    ...and C# developers don't make more money. Pay is based on the role of the task and negotiations. It has nothing to do with the language.

    Adam


    Ctrl+Z
    Monday, April 4, 2011 12:22 PM
  • Guid being a value-type, it cannot have a null reference.

    After testing it, I confirm: the VB statement does the same thing as the C# statement.

    Monday, April 4, 2011 12:41 PM
  • Dear Adam,

    I tried all the syntax combinations, all are returning null in VB.NET. Did you try your code with VB.NET?.

        '1.
        Dim myGUID As System.Guid
        myGUID = New System.Guid("F7FF66B8-602E-4378-A462-F8A7B8A1C586")
    
        '2.
        Dim obj As New System.Guid("F7FF66B8-602E-4378-A462-F8A7B8A1C586")
    
        '3.
        Dim objVB As Guid = New Guid("{dddddddd-dddd-dddd-dddd-dddddddddddd} ")
    
        '4.
        Dim objVB1 As New Guid("{dddddddd-dddd-dddd-dddd-dddddddddddd} ")
    

    Thanks and Regards, Bharath S.
    Tuesday, April 5, 2011 4:25 AM
  • Hi,

    Short and simple answer, pick the one you like best.  And change after a while if you then decide you like the other better.  Or learn both equally well.  C# and VB.Net are equally good, and once you know one you will at least be able to follow code written in the other.  You are basically learning .Net.  What the syntax is doesn't matter much.

    Microsoft makes a point of demonstrating they focus equally much on both languages and will do code demonstration in random languages.  Anders Hejlsberg placed the C# vs the VB choice as a matter of history.  Most likely job opportunities dictate which language you will end up using, but it is easy to switch language.

    One point though.  Do not decide based on a single features. If you need it, you can always create a separate assembly using that specific feature.


    ---
    Happy Coding!
    Morten Wennevik [C# MVP]
    • Proposed as answer by Cor Ligthert Tuesday, April 5, 2011 8:07 AM
    • Marked as answer by prateek203 Tuesday, April 5, 2011 6:49 PM
    Tuesday, April 5, 2011 5:41 AM
  • i see. k thanks everybody. i think i'll go with c# for now, as it's more required.
    • Edited by prateek203 Thursday, May 10, 2012 9:39 AM
    Tuesday, April 5, 2011 6:27 AM
  • I tried all the syntax combinations, all are returning null in VB.NET. Did you try your code with VB.NET?.


    Which code did you use to check that it is null? A Guid cannot be null. Never.

    Try adding this:

        MsgBox(myGUID.ToString())
        MsgBox(obj.ToString())
        MsgBox(objVB.ToString())
        MsgBox(objVB1.ToString())
    
    You won't get any NullReferenceException.
    Tuesday, April 5, 2011 5:16 PM
  • I know it is a late response, just wanted to say that although it is true that GUID is a value type as many pointed out already, you CAN make it nullable (C# code):

                                     GUID? myGUID;

    And yes, it CAN NOT be null if declared as GUID myGUID

    Thursday, August 9, 2012 2:27 PM