views:

763

answers:

7

Duplicate:


I've primarily used VB.NET, but for a variety of reasons I'm switching to C#.

(I have used C# before, but not extensively.)

I'm using ReSharper to hopefully make it less painful, and I'm wondering if anyone has advice for learning C# syntax. Any other relevant advice would be great, too.

Thank you,

Michael

+1  A: 

Don't. Stick with the one you know.

Historically VB and C# have some differences in capability, but in the future the languages are converging (not syntactically, just in capability). This means you can pick either one for just about any programming problem.

Before you pay for ReSharper, be sure to look at CodeRush Xpress, which is free for VS 2008 users.

Jay Bazuzi
I was about to say the same.
Konrad Rudolph
As I've explained in other answers, the number of companies that are looking for C# programmers compared to VB.NET programmers averages 3 or 4 to 1. It's not just technology going forward, it's maintaining what's already there, and you're 3 or 4 times more likely to work on a C# team than a VB team
George Stocker
also the number of open source projects for .NET are mostly written in C# and few bother to convert or maintain one in VB as well. it will be nice to be able to mix languages in the newer VS and .NET releases but I think knowing both is required at this point.
Brian Boatright
+5  A: 

With the help of Resharper and visual studio the switch shouldn't be too difficult. I switched back and forth a few times, I try to do C# on teams that do C# and VB on teams that do VB.

The three biggest problems I found were:

Semicolons, you always forget those when you start doing C# after doing VB. Resharper will help there.

Keywords and their translation to C# can be hard to get right at first. Shared = static, Me = this, MustInherit = abstract. etc. I found a list here that you can print out and put next to your computer. http://www.dnzone.com/ShowDetail.asp?NewsId=356 C# is a bit more standard in the naming of keywords. Knowing that a static is called a static will also help you communitate with Java, C++ and other developers.

Events are also different. Practice a bit with creating and handling events in C# and you'll get the hang of it.

Otherwise things are mostly the same.

Mendelt
+4  A: 

Having done development myself first in VB.NET and then in C# I can say the transition should be easy. You are already more than 50% there with your knowledge of the framework. Now its just a matter of learning the C# syntax.

Sharp Develop has VB.NET to C# conversion and visa versa.. and its free :)

I would write a simple program in VB.NET that uses IF statements, CASE statements, LOOPS, etc, convert it and see the difference in syntax.

I think you will find IMHO the hardest part is remembering to use braces to open and close code blocks (instead of BEGIN whatever, END whatever) and getting used to terminating lines with semicolons :)

Andy Webb
+1 for Sharp Develop
johnc
Thanks. It's a great tool I stumbled on about.... must have been six years ago (wow time flies). And it keeps getting better IMHO.
Andy Webb
+2  A: 

I found this when I was switching from VB to C# and found it to be a very good, quick reference.

Timothy Carter
A: 
  1. Practice, practice, practice. Probably obvious, but try writing a small, fun application in C#. You'll discover many questions you might not have otherwise though of plus start training yourself to think more naturally in C#.

  2. Study existing C# code bases. You could download some open source projects or even step through the .NET Framework code base.

C. Dragon 76
A: 

Resharper is a great tool, but isn't as necessary as it used to be. Upgrade to .NET Framework 3.5 SP1 to add the compile-as-you-type feature to C#.
This will allow you to see errors in your code without having to wear down the F5 key.

foson
+1  A: 

I'd recommend doing some Project Euler problems in C# to get the hang of it. You won't regret the switch (IMO).

Michael Haren