Friday 11 July 2008

VB.net to C#

So - being as pretty much 80% of .NET web development roles require the use of C# and I'm primarily a VB.net developer I've decided to get on the bandwagon and become a little more multi-lingual in programmatic terms. That's right...I'm learning C#! (Other coders who know me....well - it had to happen sometime init?!)

Now the upside to this is that it will make me a great deal more employable when hunting for a new job, the downside...you get into that repetitive situation where you're coding in 1 language...when you try and switch to one you're cool with (such as going back to VB.net from C#) you end up trying to code 1 language against the other platform! I totally remember this happening way back when I was learning Javascript. Started adding curly brackets to stuff when I moved back onto ASP (I'm talking classic ASP here so it was some time ago). I know this isn't going to last long but it still sucks a bit.

Anyways, for those VB.net developers who are wanting to learn C#. If you know your Javascript or Actionscript syntax then you're sweet. All there is to it is syntax when it boils down to it and having a grasp of the aforementioned will help you no end. Thankfully, the CLR dictates that all the methodologies are pretty much the same. Inheritance, instantiation, OOP methodologies are bang on how you'd do them in VB.net - and once you know the little quirks that'll trip you up in the beginning:
  • No more optional parameters for functions/sub routines
  • No real declaration for a Subs, Functions or property but more how you write it that defines what it is
  • You'll need to do a compilation every so often to find errors
  • You can't be slack. By this I mean, you need to be sure you keep your case sensitivity in check...VB.net does a whole bunch of automated corrections for you that you don't even notice - C# basically tells you - "That's wrong...try again".
But stick with it and within 2 weeks...you'll be blazing through no problem.
Anyways - a few sites that have helped me shed loads...

VB.net to C# Converter
Great for the little snippets when you know what you want to do but can't quite get it right in C#

VB.net to C# Comparison
Heaven send blessings to the dude who wrote this page...it's helped me no end! Shows you all the basics of VB.net and their C# equivalents from object instantiation to data type declarations.

Anyways, figured I'd throw down my 2 cents and help anyone on the same path with what knowledge I have aquired thus far.

Happy Codin'!