tags:

views:

295

answers:

13

I started my career coding in C/C++ on a vax system, but got into a few contracts where it was all VB and then became a specialist in VB, then to VB.net. Now I am aspiring to work for Microsoft and it seems that every job they post is in C/C++/C# and I can barely read C# code, it looks like the most convoluted mess to me and the inline syntax almost hurts my feelings.

I am looking for positive, non-flaming, helpful suggestions on how to pick up C# skills again. Books..Labs..etc? I have been coding simple projects using Silverlight and C# to try and work it out but it is extremely frustrating since there are very few examples that I can find that illustrate what each code set looks like. I've Googled but have yet to find anything helpful other than channel9 labs and working through some of the example code/projects from mix10.

I am not looking for a shortcut, but a good solid skills understanding. I swear it is easier to translate English to Latin than VB to C#.

+13  A: 

I personally would start by converting a VB.NET project into C#, having done VB.NET it wouldn't be difficult once you got started as they both use the same underlying CLR.

Doing it this way step by step, looking up how to convert each bit you don't understand, you'll soon end up teaching yourself C# based on you're knowledge of VB.NET and you'll see they're really not that much different!

I find them very similar now I know them both, they just have a habit of doing things 'slightly' differently.

Also, have a look at this wiki page for a summary comparison of VB.NET and C#, and check out the examples at the bottom to see some basic syntax comparisons that will give you a starting point for converting VB.NET into C#.

w69rdy
That will teach the very basics of the syntax, but completely miss C# idioms.
James Curran
Yes but from the sounds of it that's exactly what he needs. Once he has learned the basics and built up his confidence with C#, he can then look to further his knowledge and skills in more advance areas of C#
w69rdy
Thank you for the link to the wiki that has been very helpful, I am also taking your advice and converting one of my smaller VB projects into C#. Building the example projects where you re-type what you see online was not doing it for me, it never crossed my mind to convert one of my existing projects.
Varuuknahl
A: 

Scott Hanselman posts a regular column of his blog called the "Weekly Source Code", which is made of source code -- generally C# --- which you can learn from by reading.

James Curran
They are usually pretty complex examples, though. I don't see someone who's having trouble reading basic C# making much headway with those.
Anna Lear
A: 

My first choice is that given by W69rdy: convert some project you've already done in VB to C#.

Second, I would skim the C# documentation, or an online source like that suggested by James, at least once a day looking for something you don't understand. Perhaps something as simple as a language keyword you don't recognize. Then write something that uses it: even something as simple as a small snippet.

TechNeilogy
+1  A: 

Buy "Head first C#" and enjoy yourself coding. It is the best book (according to me and a few others) on the market learning C#.

alt text

BennySkogberg
Thank you for the book reference!
Varuuknahl
+4  A: 

Since VB.NET and C# are both first-class object-oriented .NET languages that compile down to the nearly the same CIL code, I find it fairly easy to switch between the two. Most of the learning curve in .NET comes from learning the myriad APIs; syntax doesn't take terribly long to pick up.

I'd recommend a good book that focuses on the language of C# (that is, not a framework such as Winforms, Silverlight, or WPF). A book that I really liked was Illustrated C# 2008 by Daniel Solis. It's great at exposing the C# language from end to end. (NOTE: Although it says "Illustrated" in the title, it's not filled with lots of pretty pictures. "Illustrated" simply means that the author uses lots of helpful diagrams to explain concepts).

Also, I spent a good deal of time solving math problems at http://www.projecteuler.net in order to learn C#. It helps to have real problems to solve to learn a language and Project Euler offers problems that are small enough that you can still focus on learning different aspects of the language.

Ben McCormack
Just because code compiles down to the same thing does not mean they are easy to switch between. For example F# also compiles to CIL but is much different than VB.Net and C# due to its functional nature. But both VB.Net and C# are ALGOL like so that would make them easier to compare to each other.
Matthew Whited
@Matthew that's a good point. They're not easy to switch between just because they compile down to the same thing. I'll try to clarify.
Ben McCormack
Thank you for the book reference and link to Project Euler I have never come across that before.
Varuuknahl
The Project Euler site is interesting. I never knew something like that existed outside Google's CodeJam and TopCoder.
Alex Essilfie
@Alex I hadn't heard of Google CodeJam or TopCoder, so thanks for the references! I think ProjectEuler's challenges are more for personal enrichment than for competition, but it's a great place to test your programming chops.
Ben McCormack
A: 

If you are looking for a quick read and tutorial, this one will work. I agree with @TechNeilogy and @W69rdy that converting a program from VB.NET to C# will help with understanding the similiarities and differences between the languarges.

I converted a VB.NET Windows service to a C# Windows service and it helped greatly with trying to learn C#.

AndHeCodedIt
A: 

I was a VB .NET programmer as well. I found that using Jetbrain's Resharper Visual Studio plug-in really helped my learning curve. I was initially converting/optimizing a VB .NET project into C# and I found the coding assistance tools really helpful. Most of the time, I was just trying to find the C# equivalent so code completion usually put me in the right direction.

Rod
A: 

I've also recently been moving to C# from VB - I've found this converter invaluable as a learning tool when you don't know a bit of C# syntax but you can write it in VB.

PhilPursglove
A: 

You should start with some C# tutorials in internet to understand the how to work with c#, then read a book with maximum 300 pages. After that you can start the converting from VB to C#. It is not difficult. Good luck.

David
A: 

I use both vb.net and c# at work. Sometimes in the same project even. Honestly, when you switch back and forth, after the first couple misplaced or missing ; or Dim's, it's pretty easy to jump between the two. The rest of the stuff (class modifiers, event handlers, etc.) is only a quick google away.

dotjoe
+2  A: 

It's odd that you are having this difficulty if you can still remember anything about C. I have a similar background but I don't find C# hard to read at all.

Are you getting confused by LINQ or lambdas / anonymous methods? EDIT you say it's LINQ: here are some links for LINQ.

  • The LINQ syntax is different in VB from C# and there's not much help out there for the VB syntax. The MSDN 101 VB LINQ samples are good, and I also liked the coverage in the book Programming VB 2008.
  • Lambdas are a way of writing methods inline that might be the "inline syntax" you are referring to? In which case, just read up on them and try them out: you could try them out in C# or VB.Net.

There were some useful articles on differences between C# and VB.Net in Visual Studio magazine back in Jan 2008.

You might also be interested in the question "what's allowed in VB that is prohibited in C# (or vice versa)"

Full disclosure: the bottom part of this answer is copied almost unchanged from this question on converting C# knowledge to VB.Net

MarkJ
You were right I was mostly looking at LINQ expressions. I have been building silverlight 4 business apps and trying to find examples for LINQ expressions which are impossible to find for VB.Net and I have been trying to convert them and it is very frustrating to say the least. The Visual Studio magazine articles were very helpful. Also thanks for the link to the other question.
Varuuknahl
I totally sympathise, I have the exact same problem and I do find C# LINQ hard to read as it is different from VB LINQ. [Oh, it looks like we're not the only ones](http://msdn.microsoft.com/en-us/vbasic/bb688088.aspx). I will edit my answer with some links about LINQ. The [101 VB.Net LINQ samples on MSDN](http://msdn.microsoft.com/en-us/vbasic/bb688088.aspx) are useful, I also liked the coverage in the book [Programming VB2008](http://rads.stackoverflow.com/amzn/click/0596518439)
MarkJ
+1 for the link *What VB developers should know about C#* and all of the other great links.
Otaku
A: 

The only way you are really going to make the step across, is to just make the step across and run with it!

Sure, check out a basic tutorial or read a guide on C# to learn the syntax basics, but then you need to find a reasonably simple, self-contained project to get stuck into. If you know some of the .NET framework (which you presumably do), then the jump won't actually be that great. Obviously, don't pick a vast, complex, mission-critical system to start with!

In fact, although my current project is my first c# project, I can't believe I didn't make the switch earlier. Apart from enjoying C#, I'm also finding it easier because I'm finding there are more good quality examples around.

CJM
A: 

I don't mean this patronisingly, but the answer is to simply start coding in C#!

There are plenty of books, resources, training CDs (check out AppDev.com for some great video based training) but nothing compares to just coding for real-life problems!

(And I agree with a previous comment about converting a recent project to C#.)

"That which we learn to do, we learn by doing" Aristotle

Chris