Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Celebrity Deathmatch (VB.NET vs C#)

Celebrity Deathmatch (VB.NET vs C#)

Scheduled Pinned Locked Moved The Lounge
csharphtmlcssvisual-studio
80 Posts 24 Posters 53 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Michael Kingsford Gray

    VB is better because I use it more often, and have more experience with it than C#. Do I get points for honesty?

    K Offline
    K Offline
    KP Lee
    wrote on last edited by
    #70

    Michael K Gray wrote:

    Do I get points for honesty?

    I don't think so, at least in the rules set out. The rules kind of limit the playing field to people who have a fairly good knowledge of both. The fact that you can turn out code more quickly (and I assume accurately) in VB is offset by those who can say the same about C#. I wouldn't worry about it, this battle is all tongue-in-cheek(TIC). Your point just reinforces that everything said here has to be TIC.

    1 Reply Last reply
    0
    • X xympa

      in C#:

      i_can_do_this(); and_this(); //in the same line

      Because of the delimeter, sometimes it makes sense not to waste one line and make the code more readable, especially when assigning multiple variables in the same context. -- Turns out you can do it in VB with ":" check the reply bellow.

      modified on Tuesday, March 29, 2011 7:11 PM

      O Offline
      O Offline
      obermd
      wrote on last edited by
      #71

      VB has a ":" colon to seperate multiple statements in the same line. statement1 : statement2

      Mike

      X 1 Reply Last reply
      0
      • O obermd

        VB has a ":" colon to seperate multiple statements in the same line. statement1 : statement2

        Mike

        X Offline
        X Offline
        xympa
        wrote on last edited by
        #72

        I did not know that, thank you for correcting me, i don't use VB much ^^ feel free to downrate my comment.

        1 Reply Last reply
        0
        • X xympa

          in C#:

          i_can_do_this(); and_this(); //in the same line

          Because of the delimeter, sometimes it makes sense not to waste one line and make the code more readable, especially when assigning multiple variables in the same context. -- Turns out you can do it in VB with ":" check the reply bellow.

          modified on Tuesday, March 29, 2011 7:11 PM

          K Offline
          K Offline
          KP Lee
          wrote on last edited by
          #73

          i_can_do_this(); and_this(); /*in the same line*/and_thistoo(); Try that with //!!!

          1 Reply Last reply
          0
          • K KP Lee

            Nishant Sivakumar wrote:

            VB.NET supports by-ref extension methods. As of 4.0, C# does not.

            WHAT!!! I don't have 4.0 version. This continues to work in 3.5: void step1(ref int x)... Are you saying all legacy C# code that uses that convention is now broken in 4.0, or did I misunderstand what you said? One thing I do have to do in 3.5 is initialize the int variable's value being passed. (Unless I use out instead of ref.) Something is rather goofy in VB.NET, I can pass a referential object as a by val field if I want. (It, of course, remains by ref.)

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #74

            KP Lee wrote:

            WHAT!!!
            I don't have 4.0 version. This continues to work in 3.5: void step1(ref int x)...
            Are you saying all legacy C# code that uses that convention is now broken in 4.0, or did I misunderstand what you said?

            You did misunderstand what I said :-) I did not mean the method arguments, I meant the source object. In VB the source object itself can be passed by reference.

            Regards, Nish


            Are you addicted to CP? If so, check this out: The Code Project Forum Analyzer : Find out how much of a life you don't have! My technology blog: voidnish.wordpress.com

            1 Reply Last reply
            0
            • O obermd

              VB has Explicit Event handlers VB:

              Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

              End Sub
              

              C#:

              private void Form1_Load(object sender, EventArgs e)

                  {
              
                  }
              

              This comes in real handy when you need the same event to handle multiple controls on a form.

              Mike

              K Offline
              K Offline
              KP Lee
              wrote on last edited by
              #75

              obermd wrote:

              VB has Explicit Event handlers

              So??? You can handle multiple controls with the same function in C#. I have a 7X7 arrary of text boxes where the name is "n" plus the two index values converted to strings and appended. I happened to only need 9 events to go to the same function. I think you misstated this:

              obermd wrote:

              you need the same event to handle multiple controls

              I think you meant "you need the same function to handle the same event in multiple controls" Personally I really like C# a lot better in this respect. This could just be because of my inexperience with VB, but I simply could not bind the events directly to the object in the array of text boxes, I had to create nine named fields, set them equal to the explicitly indexed box in the array, and manually list out all nine named fields with their event type in the function declaration. I shudder to think what the code would look like with all 49 events pointing to the same function. In C# each event delegates to the same function in a separate command, it has no direct tie to the function declaration. This is great, I just add the events directly from a do loop. I have no idea how to tie events to a function in a do loop in VB. (Just imagine the swearing I did when it wouldn't work, the frantic scrambling trying to find the documention of how multiple events to 1 function work in VB, then finding out specifically indexed controls in an array can't be tied to a function. ARRRGGGG.) OK, I had an advantage with C#. I took classes, that required books, and that mainly trained me to do some of this stuff.

              1 Reply Last reply
              0
              • O obermd

                VB has Explicit Event handlers VB:

                Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

                End Sub
                

                C#:

                private void Form1_Load(object sender, EventArgs e)

                    {
                
                    }
                

                This comes in real handy when you need the same event to handle multiple controls on a form.

                Mike

                A Offline
                A Offline
                AspDotNetDev
                wrote on last edited by
                #76

                C# and VB are actually pretty similar in this respect. In C#, the assignment of events is explicit, but it is usually "hidden" from you (in the designer.cs file). In fact, the designer.cs file is part of the reason partial classes exist.

                [WikiLeaks Cablegate Cables]

                1 Reply Last reply
                0
                • T the Kris

                  Nope, 'cechode' wrote: General Re: Celebrity Deathmatch (VB.NET vs C#) Pin member cechode 23hrs 30mins ago i'm not a vb guy anymore but when i was i LOVED exit on first failed step. ( instead of nested if's ) BTW, I would use bool s = step1() || step2() || step3(); to execute until first true result.

                  K Offline
                  K Offline
                  KP Lee
                  wrote on last edited by
                  #77

                  You're right, an added benefit is that "s" is true if one step passed instead of the counter-intuitive true if all steps failed. Isn't the example I first commented on, an "exit on first failed step" process?

                  1 Reply Last reply
                  0
                  • C cechode

                    i'm not a vb guy anymore but when i was i LOVED exit on first failed step. ( instead of nested if's )

                        Select Case False
                            Case Step1()
                            Case Step2()
                            Case Step3()
                        End Select
                    

                    cant do that in C#

                    M Offline
                    M Offline
                    Marc Greiner at home
                    wrote on last edited by
                    #78

                    Did you show this VB6 code because you think it is a nice way of writing it? Why not write it like so: VB6: If Step1() Then If Step2() Then Step3() C# (more concise): if (Step1() && Step2()) Step3();

                    1 Reply Last reply
                    0
                    • N Nish Nishant

                      Oh sorry, it's so well known that I didn't think you'd need code to back it up :-) See this blog post: http://blog.gadodia.net/extension-methods-in-vbnet-and-c/[^]

                      Regards, Nish


                      Are you addicted to CP? If so, check this out: The Code Project Forum Analyzer : Find out how much of a life you don't have! My technology blog: voidnish.wordpress.com

                      M Offline
                      M Offline
                      Marc Greiner at home
                      wrote on last edited by
                      #79

                      Your argument does not work, because, as someone else suggested, in C# you would simply use a struct, not an enum. Check this for an example: Comparing enum flags in C# http://stackoverflow.com/questions/1086618/comparing-enum-flags-in-c

                      N 1 Reply Last reply
                      0
                      • M Marc Greiner at home

                        Your argument does not work, because, as someone else suggested, in C# you would simply use a struct, not an enum. Check this for an example: Comparing enum flags in C# http://stackoverflow.com/questions/1086618/comparing-enum-flags-in-c

                        N Offline
                        N Offline
                        Nish Nishant
                        wrote on last edited by
                        #80

                        Marc Greiner at home wrote:

                        Your argument does not work, because, as someone else suggested, in C# you would simply use a struct, not an enum.

                        Uhm, I think you are under a misunderstanding here. I am not arguing anything here :-) I did not write that blog entry. This thread is a fun-thread to talk about features (including useless ones) that exist in one language but not in another. VB allows ref extension methods (where the source is passed by ref), C# does not. I am not saying it has any utility whatsoever. I don't use VB. I use C++ (native) and C#. There may be cases where that is useful to have, but I am sure it's not a deal breaker. In future, please don't jump to assumptions about whether someone is making an argument when they are not! :)

                        Regards, Nish


                        Are you addicted to CP? If so, check this out: The Code Project Forum Analyzer : Find out how much of a life you don't have! My technology blog: voidnish.wordpress.com

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups