C# from VB.NET – Some helpers

Thursday December 31st 2009

Following on from the post about iPhone development using MonoTouch and C#, I thought I would point out the fact that at the moment MonoTouch doesn’t support Visual Basic for iPhone development. Mono and MonoDevelop themselves do support VB, but just not for iPhone dev just yet. The MonoTouch team say it is on the roadmap, just no date as of yet.

 

So where does that leave the Visual Basic developer? Well, if they want to write iPhone apps using the .NET framework, then needing to learn some C#.

 

For many VB developers, who came to .NET from VB6 (and below), stepping up to a fully object orientated language and the .NET framework was tough enough to grasp, let alone taking on dealing with curly braces as well. Whilst VB.NET is not the same language as VB6, Microsoft did a pretty good job at smoothing the upgrade path for developers (certainly with VS2005 and .NET 2.0 upwards anyway).

 

Many developers will probably have some exposure to other languages, such as PHP, JavaScript, or even Java (remember that?), all of which would make learning C# a bit easier, but if you haven’t then don’t worry too much. If you know the .NET framework, then you’re already halfway there.

 

I myself trained in C many many moons ago, and more recently have been doing quite a lot of PHP and JavaScript, so braces and semicolons don’t worry me too much. Most of my .NET work has been in VB.NET in the past, but that’s mostly been down to business needs.

 

However, I’m a firm believer that if you can program you can program, and learning another language is mostly a case of learning where the dots go. Syntax can be fiddly at the best of times, even with a language you know every day. That’s the beauty of a good IDE.

 

All that said, you could ask why not learn Objective-C then? Well, I think you should learn at least the basics, if not more, but to get up and running quickly and become productive sooner, then being able to use your .NET skills can only be a good thing.

 

So, you know how to code, and you know the .NET framework, but how can make the switch to C# easier?

 

There are a huge amount of resources online, and you can spend days trawling through stuff that isn’t of any real use, but I thought I’d share some of the more useful stuff I’ve found to help you along.

 

A fantastic starting point is the Comparison of C# and Visual Basic .NET on Wikipedia. It covers many of the fundamental differences between the two languages.

 

http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Visual_Basic_.NET

 

Following on from that, once you’re comfortable with the differences and just need a reference as to what a keyword is, or where to put that semicolon, then ASP Alliance have a great C# and VB.NET Comparison Cheat Sheet. Download the PDF version and print it out to have to hand when working.

 

http://aspalliance.com/625

 

Then, if you just happen to stumble across a snippet of code you don’t understand, or want to take some existing VB.NET code and put it into your C# project, then you can just use the brilliant Telerik Code Converter, which translates VB to C# or back again, at the click of a button.

 

http://converter.telerik.com/

 

So those are just a handful of the more useful tools I’ve found helpful. I hope you do to, and feel free to let me know if you have any others.

  • Share/Bookmark

Leave a Reply