Converting to and from VB and C#

The easiest way to convert from VB to C# or C# to VB is this: learn the language.

I am a BIG VB fan. I've been using VB for nearly 6 years, both VB6 and VB as a part of the .NET framework, and I get arround when it comes to VB. But I recently came across a problem when developing the ClubStarterKit, I needed to convert the whole solution into C# for those who want to use C#. So I got to thinking and I really didn't want to learn C# at the time. I just wanted to convert it and not deal with it any longer.

But here's the problem with that methodology: I started converting the VB solution into C# using my favorite converter (Econ NetVert) and there were errors... many in fact. So I tried to go in an figure out the various problems. I seemed to think there was just 1 solution that would fix all these problems at once and all I had to do was just take the time and make it work. But in my case, that didn't work so well.

So I already knew I was taking this Java class. Turns out that the syntax for Java is pretty similar to that of C#. The only difference I see is that the libraries are VERY different and some of the ways you get user input and what not is very different as well.

I'm learning Java but I am also sort of learning how C# works. It's starting to click and now I can look at a piece of C# code and think, "what does that do" and answer it!

Moral of the story: Learning a language is invaluable when you have to do converting. There really isn't any excuse the C# or VB guys can make to not know both languages. They are both VERY similar and I think converting between one and the other isn't hard as long as you take the time to go ahead and learn the language your are trying to convert it in. REMEMBER: C# and VB both convert to IL!

I think I am going to put in tips for those converting from C# to VB soon. I think that should help Rob Connery and some others figure out what this VB thing is :)

9 Comments

  • Here's the deal: VB has done more for programming and software than any other language - both good and bad. I started out with VB. I used it in Access, VB5, VB6, and jumped ship with VB.NET.

    VB.NET is a "crutch" language and I have a standing bet with 4 different friends that VB support in .NET will be phased out by v4. I'll probably lose.

    There's a reason Microsoft stated that C# is their preferred language for .NET (at least when .NET 1.0 came out). It's a language that was built specifically for the platform. VB.NET is a horseshoe, a crutch for now that is supposed to ween you from the VBx/COM days.

    Some people like it - I can't stand it. It's wordy, it's ugly, it's... just blech. It hales from a past rife with weirdness (VB/COM) that we're all trying to forget and when I see it... i ... i ... i ... I can't face it.

    Tell ya what. I'll give you $100 if you learn C#. When you decide to change forever, you gimme back $50. Deal?

  • C# and VB.NET both merge to IL. I really haven't seen any documentation that says that C# is "prefered". Much of the compilers in .NET are written in VB... although most of the .NET framework are written in C#.

    VB is really verbose and doesn't require extensive knowlege of what sort of things you can and can't do with a language. Either way, it's really the same thing, Rob. There really aren't an performance differences between the two.

    I am learning C#. I could probably write all my stuff in C# at this point. Maybe I should start doing that. I just want to be fluent in both... just having knolege of C# really won't guarantee you a job. VB is a good thing to know.

    (BTW, Rob... I'm just giving you a hard time :)... no hard feelings, right?)

  • @ Rob Conery....

    " VB.NET is a "crutch" language and I have a standing bet with 4 different friends that VB support in .NET will be phased out by v4. I'll probably lose."

    NO Way.....

    This scenerio mentioned will never take place. VB is the First Child for Microsoft, with huge developers figure behind it. C# was created only to win Java crowd, nothing else. Since they were already developing new language from scratch they adopted C#, with no other reason.

    Microsoft could have easily developed .net with VB, but thata another story. RUBY now wins and competes with micrtosoft at each and every stage. And the output from microsoft as IronRuby is not very far.

    MVC model from Microsoft is very near, as per what i have heard. Microsoft is introducing VBx ( Dynamic VB ) very soon. They are giving VB a new shape and name with this new Birth, so VB is here to stay as long Microsoft lives.

    BTW Rob, you should blog more about Microsoft MVC model, since you know it more better than us. Your subsonic model has done wonders with MVC way.

    Long live Subsonic.

  • I agree, SoftMind. Rob is knolegable about MVC and should blog more about it.

    (Long live SubSonic!)

  • There seems to be a reluctance to name either language "preferred".

    C# is the platform language, it was created hand in hand with .Net.

    Even if most things get designed with C#, it all has to work well with VB.Net too or get redisigned


  • C# is the platform language, it was created hand in hand with .Net.

    Actually some of .NET was written in VB.

  • Bah I say! In terms of docs - well I don't know if there's a KB article and I looked and can't find the source - BUT I do know it's the reason I switched: MS prefers C# for the .NET platform. This was well known when 1.0 came out. I promise.

    Yes, they both compile to IL but there are things you can do in C# that you can't in VB - for a reason.

    To be honest, I think MS was caught off-guard with how many people stuck to VB.

    Finally - ever notice how the DLR will support VB? Weird eh? If you ask Jon Lam he'll tell you that "MS is trying to get VB back to it's dynamic roots" - I heard this on .NET Rocks. Looks like I might win my bet after all.

    Zack I'm tellin ya - if you go C# and learn to read the syntax, you'll never want to read another line of VB. That goes for you too Softy!

  • Bush would use C#...

  • Oh, you're just trying to convert me, Rob :)

    I am going to learn C# but keep my VB *muscles* too.

Comments have been disabled for this content.