Making the switch from VB.net to C#
-
For the last 7 years I’ve been doing all of my (professional) programming in VB. Now I want to make the long overdue leap to C#. For no real other reason than I have been doing a fair bit of Objective-C in my spare time and I'm sick of syntax hopping for the first couple of blurry hours on Monday morning. I'm not looking to start another C# v VB discussion, and I’m not looking for the noobie VB -> C# conversion charts. What I’m asking is from all you C# gurus what little tricks, tips and advice can you offer a non-noob, who really should have worked in both platforms from day one?
-
For the last 7 years I’ve been doing all of my (professional) programming in VB. Now I want to make the long overdue leap to C#. For no real other reason than I have been doing a fair bit of Objective-C in my spare time and I'm sick of syntax hopping for the first couple of blurry hours on Monday morning. I'm not looking to start another C# v VB discussion, and I’m not looking for the noobie VB -> C# conversion charts. What I’m asking is from all you C# gurus what little tricks, tips and advice can you offer a non-noob, who really should have worked in both platforms from day one?
The language capabilities are basically the same. C# is less verbose and needs more semi-colons and braces; the one thing I appreciate is VB's
Handles
keyword. New goodies (anonymous delegates, LINQ, lambdas, ...) typically get introduced in C# first, so that should not pose any problems. In practice the main differences I'm aware of are: 1. VB is not very strict by default; you can get away with a few things other languages don't allow. So you might want to addoption strict on
and the like (if you haven't done so already) and retest, before engaging in a conversion. 2. There are a number of VB-specific namespaces (e.g. Microsoft.VisualBasic.Compatibility), which you could continue to use in another language, although I wouldn't recommend that. 3. Visual Studio does a couple of special tricks to ease the VB->VB.NET transition. Example: all forms are auto-instantiated. 4. Some environmental aspects are different, e.g. Visual Studio offers a splash screen out of the box in VB.NET, not in C#. There probably are a few more issues of this kind, I don't know. In conclusion, if your code started as VB6, was then made to work in VB.NET, then I'd say it deserves some refactoring; and if it is quality VB.NET code, I wouldn't expect real issues. :)Luc Pattyn [My Articles] Nil Volentibus Arduum
-
The language capabilities are basically the same. C# is less verbose and needs more semi-colons and braces; the one thing I appreciate is VB's
Handles
keyword. New goodies (anonymous delegates, LINQ, lambdas, ...) typically get introduced in C# first, so that should not pose any problems. In practice the main differences I'm aware of are: 1. VB is not very strict by default; you can get away with a few things other languages don't allow. So you might want to addoption strict on
and the like (if you haven't done so already) and retest, before engaging in a conversion. 2. There are a number of VB-specific namespaces (e.g. Microsoft.VisualBasic.Compatibility), which you could continue to use in another language, although I wouldn't recommend that. 3. Visual Studio does a couple of special tricks to ease the VB->VB.NET transition. Example: all forms are auto-instantiated. 4. Some environmental aspects are different, e.g. Visual Studio offers a splash screen out of the box in VB.NET, not in C#. There probably are a few more issues of this kind, I don't know. In conclusion, if your code started as VB6, was then made to work in VB.NET, then I'd say it deserves some refactoring; and if it is quality VB.NET code, I wouldn't expect real issues. :)Luc Pattyn [My Articles] Nil Volentibus Arduum
Luc, thankyou very much for taking the time to respond. I think my ignorant self may have been ambiguous, sorry. What I should have asked is Making the switch from VB.net to C#. I sometimes forget there was a vb world before .net Sorry, but thanks again. p.s. i've just edited the title
-
Luc, thankyou very much for taking the time to respond. I think my ignorant self may have been ambiguous, sorry. What I should have asked is Making the switch from VB.net to C#. I sometimes forget there was a vb world before .net Sorry, but thanks again. p.s. i've just edited the title
No problem, I think I covered both cases in one anyway, while assuming you already had VB.NET, given your choice of forum. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
For the last 7 years I’ve been doing all of my (professional) programming in VB. Now I want to make the long overdue leap to C#. For no real other reason than I have been doing a fair bit of Objective-C in my spare time and I'm sick of syntax hopping for the first couple of blurry hours on Monday morning. I'm not looking to start another C# v VB discussion, and I’m not looking for the noobie VB -> C# conversion charts. What I’m asking is from all you C# gurus what little tricks, tips and advice can you offer a non-noob, who really should have worked in both platforms from day one?
Hope this blog post will be useful to you. .NET Code Conversion[^]
thatraja
FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI | Nobody remains a virgin, Life screws everyone :sigh:
-
For the last 7 years I’ve been doing all of my (professional) programming in VB. Now I want to make the long overdue leap to C#. For no real other reason than I have been doing a fair bit of Objective-C in my spare time and I'm sick of syntax hopping for the first couple of blurry hours on Monday morning. I'm not looking to start another C# v VB discussion, and I’m not looking for the noobie VB -> C# conversion charts. What I’m asking is from all you C# gurus what little tricks, tips and advice can you offer a non-noob, who really should have worked in both platforms from day one?
A few months ago I finally made the same switch, and I don't regret it. The few things that took a bit of time to get used to: - A few type conversions that are handled automatically by VB need to be explicit in C#. It does however force you into better programming. - If you are working with forms: Forms are instances of the Form object (well, as they should be in OOP). The default form you get in VB however is static. - If you're working with Visual Studio: use the latest one (2010); in older versions the intellisense felt a bit slower in C# compared to VB (might be just a 'feeling'). Good luck.