CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Join Date
    Jun 2005
    Location
    Turkey
    Posts
    54

    Difference between c#.net and VB.net

    Hi!
    I'm learning c# and some people say c# and VB.net is same powerful but VB.net is easier so it is better if i use VB.net. But i dont know why, i hate VB. What is the difference between VB.net and c#? The reason of c# to be the the main language of .net is to be like java? What do you think?

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Difference between c#.net and VB.net

    I prefer C# to VB.NET for various reasons :

    (1) Fewer keystrokes. It takes fewer keystrokes to write in C# than write in VB.NET.
    (2) Curly brackets for blocks. I find VB.NET code seems to be all "jumbled" up, especially between while loops, if statements etc.
    (3) 'unsafe' code. In VB.NET you have to do everything through GCHandle. It's far nicer to write "fixed (byte *pbArray = abArray)" in my opinion.
    (4) Events and Delegates handling. It's far superior in C# than in VB.NET in my opinion.
    (5) "using". I use this a lot to make sure that code is always executed on exiting blocks of code. I don't believe VB.NET has anything similar.

    I just find VB.NET 'clunky' to use. For instance instead of writing

    Code:
    int nValue = 0;
    you have to write

    Code:
    Dim nValue As Integer = 0
    in VB.NET which is very long winded.

    Just my opinion and personal taste of course.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Join Date
    Oct 2001
    Location
    Melbourne, Australia
    Posts
    576

    Re: Difference between c#.net and VB.net

    I think Darwin is right on the Vb.Net being very jumbled. C# is far cleaner and (once you are used to it) easier to read.

    Also, Vb.Net does not support operator overloading. Granted, you may not use it often, but sometimes it is useful. There may also be other things, but I don't know them off the top of my head.

    BUT, C# does not support shared variables (i.e. variables that are static to a method, not a class). Of course, there are workarounds for this.

  4. #4
    Join Date
    Jun 2005
    Posts
    3

    Re: Difference between c#.net and VB.net

    some times you have to stick to the company policy to code this or that way. If you are not restricted then find you fun with either of them. I believe that any average project can be carried out with equal success by coding on any supported CRT language.

    I enjoy C -style ever since so I was glad to jump to C#. It is obvious to me that people have designed this beauty with love in their hearts.

    It is not impossible that VB as well as JavaScript.NET and others have been appended to the .NET project to support "Any language" claim.
    +&up;

  5. #5
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Difference between c#.net and VB.net

    Both C# and VB.NET compiles to IL which runs in CLR. That means that C# and VB.NET could have the same features. But they don't. VB.NET is missing some constructs available in C# and C# doesn't implement all features of CLR. This differences are ment by other on this post.

    Personaly, I also prefere C# over net. In fact, I consider Visual Basic to be a historical failure. C# code is better structure and easier to read. Thats my opinion.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  6. #6
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Difference between c#.net and VB.net

    Personally I believe that VB.NET was added so that VB6 people didn't feel left out. Mind you according to statistics VB6 people are having real trouble changing to the object-oriented world of .NET, whereas C++ have no problems with C#.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  7. #7
    Join Date
    Mar 2005
    Location
    Chicago, IL
    Posts
    69

    Re: Difference between c#.net and VB.net

    What about the capabilities?

    Can VB.Net do every thing that C# does , I mean can we implement the same functionality in both the languages... are there any "if's" and "but's"...
    There has been an alarming increase in the number of things I know nothing about .

  8. #8
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Difference between c#.net and VB.net

    I think we've already covered that. No - C# has more things that it can do that VB can't than things VB has that C# doesn't.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  9. #9
    Join Date
    Jun 2005
    Location
    Turkey
    Posts
    54

    Re: Difference between c#.net and VB.net

    well i wonder why does the microsoft certified tecnical education centers usually teach VB.net instead of c#(It is in my country)? Is it like this in other countries?

  10. #10
    Join Date
    Feb 2005
    Posts
    106

    Re: Difference between c#.net and VB.net

    That would be because of the sheer volume of deployed (and maintained) VB applications. Not neccesarily because of the merits of VB.NET as a development language.

    Just my 2 cents.

    Regards.

  11. #11
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Difference between c#.net and VB.net

    And also probably for another point which I made which was C++ people don't have any problems moving to C#, but VB6 programmers have problems moving to VB.NET (according to surveys) because of the conceptual change to object orientation.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  12. #12
    Join Date
    May 2009
    Posts
    1

    Cool Re: Difference between c#.net and VB.net

    oh guys guys, come on, thats not true.

    .net is targetted for language integration (the mean the word real integration).

    C#.NET & VB.NET are equal powerfull and you can do everything in in both the languages.

    there are syntax differences. you know, there is no inbuilt datatype called DateTime in C#.NET, it borrows from the CTL, it doesnt mean its a lacking feature in C#.NET. there is no keyword unsafe in VB.NET thats too vice versa. They intented to avoid memory leaking which used to be god **** issue with pointers all the time, but still u can obtain the same features with alternative machanism.

    You know, you cannot see the events available in the IDE window for C#.net project in which VB.NET makes it very simpler for you.

    but technically speaking, if you ignore those kind of small things and syntax differences both are equal powerfull language. You can refer to the below white paper from Microsoft.

    In most of the large & ERP products they prever as VB.NET as front end and C#.NET for building the middle layer (business logics, and rest of the things).

    That explains putting the right things in right place, 'coz till now no other language can beat VB.NET in UI perspective.

    the thing is its the matter of comfortability on which languages you used with.

    Im the person who is using both the languages equally it almost all my projects to utillize the best of both in right situations.

    Note: there is a technical difference between both the languages if you look into the begining of the IL code. (VB.NET does one additional validation where C#.NET doesnt)

    White Paper Link: http://support.microsoft.com/kb/308470

  13. #13
    Join Date
    May 2009
    Location
    .NET 3.5/VS 2008
    Posts
    7

    Re: Difference between c#.net and VB.net

    I'm a VB6 programmer and when i first saw VB .NET and tried to learn it it was **** near impossible, they changed everything and made it completely different, VB6 is dead, but its still the most widely used language in the world. So now i'm learning C# from scratch and not even going to VB .NET i know Vb6 too well and i'm too comfortable with it so C# is my choice.

  14. #14
    Join Date
    May 2007
    Posts
    1,546

    Re: Difference between c#.net and VB.net

    C#.NET & VB.NET are equal powerfull and you can do everything in in both the languages.
    That's not true. The biggest difference is that VB.NET doesn't allow you to use unsafe code (as mentioned previously). It is actually a pretty major issue which would make it prohibitive to use VB.NET in certain scenarios. Those scenarios are ones I work with regularly enough. So with that in mind, they aren't equally powerful

    Other minor (but worth mentioning) differences are:

    1) VB.NET is case insensitive whereas C# is case sensitive. The result being that you can create code in C# which cannot be accessed from VB.NET

    Code:
    public void Method () { Console.WriteLine ("A"); }
    public void method () { Console.WriteLine ("B"); }
    That's valid in C# but not in VB.NET. Sure it's bad programming practice, but it might be an issue.

    VB.NET also has a form of duck typing, C# does not. So in VB.NET you can do:

    Code:
    object o = new MyClass ();
    o.MyMethod (); // Call a method on 'MyClass'
    You can't do this in C#. You have to use reflection:

    Code:
    object o = new MyClass ();
    o.GetType ().GetMethod ("MyMethod").Invoke ();
    That explains putting the right things in right place, 'coz till now no other language can beat VB.NET in UI perspective
    Not quite sure what you mean by that one.
    Last edited by Mutant_Fruit; May 20th, 2009 at 12:12 PM.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  15. #15
    Join Date
    Mar 2009
    Posts
    51

    Re: Difference between c#.net and VB.net

    C# does not support indexed properties - something which C++/CLI (and I think VB.net) does support.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured