tags:

views:

324

answers:

10

What are some good exercises that an intermediate/advanced VB.NET web programmer should to do gain syntax chops on C#?

I imagine some good examples would be:

  • algorithms or project exercises that run the gamut of C# syntax
  • reference material
  • list of the key syntactical differences that VB.NET programmers should be aware of
+1  A: 

Play with your own code using an automatic converter.

It should work fairly well for most things. You'll mostly just need to figure out how to rework lambdas and some other situations like that.

Reflector is also very good to help you figure out how to play with converting your code.

As for learning the differences, see MSDN's white paper on this. It's a bit out of date, but a good starting point. A more complete, but less textual reference-like comparison, is available here.

Reed Copsey
+1 for Reflector. Indeed.
Yacoder
+2  A: 

I made the trasition by taking one of my hobby projects that was done in VB.NET and re-write it in C#. That got me started in a good manner; learning the syntax while working in a known problem domain, while also providing real-world problems to solve.

Fredrik Mörk
+1  A: 

Wikipedia has a great article on this:

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

Kelsey
+8  A: 

I think best exercise would to build something for yourself.

This way you can to define your scope, to "negotiate" new features and to write new code just for fun.

You could also to solve again problems you already know; for instance, I recommend trying to solve some problems from Project Euler in C#.

Rubens Farias
+1. Was going to suggest Project Euler
Binary Worrier
@binary, that's very addictive; its makes me feel dumb everytime
Rubens Farias
+1  A: 

Look up the very basics (how to define a function, how to define a variable), then start coding C# in a real project. Look stuff up once you get stuck (or try the automatic converters mentioned in another answer). The differences are not large, so it will not delay your project significantly. Since there is (almost) a 1:1 correspondence between VB.NET and C# code, it's usually okay to "think VB.NET" and then write your code in C#.

After you are familiar with the syntax, google for the differences between VB.NET and C# (i.e. what can you do in C# that won't work in VB.NET -- e.g. anonymous methods) and rework those things where C# allows for a more elegant solution.

Heinzi
+1  A: 

If you have a basic grasp of the language, I would recommend working through project Euler (http://projecteuler.net/) in C#. It starts out very easy and slowly becomes more and more difficult, requiring you to learn more about the language [you are using to develop the solutions] in order to solve the problems.

It may make sense to pick up a C# reference book, if you haven't already.

I think you will be surprised how quickly you transition.

Robert Venables
A: 

Practice forgetting VB.NET [:)], then learn C# as a usual person would learn. I don't think VB.NET-coders have some special way of learning C#... You'll just be familiar with the .NET class library, it's a plus.

Yacoder
+1 for forgetting. If there was a hate-vb tag... I would get the platinum badge.
snicker
+3  A: 

this should take care of #3

Comparision

ps
I have seen a lot of comparison articles but this one is my favorite..It gives sample code for c# and vb.net for most of programming constructs..
ps
+1  A: 

Because programming in .NET is more about the Framework than any specific language or syntax on top, the MSDN documentation is invaluable for crossing over C# and VB.NET barriers because it contains one-to-one samples of using C# and VB.NET syntax for .NET common elements. For example if you look up delegates you will find the same sample in both syntaxes.

For syntax-specific elements other people have posted some good sources.

John K
A: 

A good excercise would be trying to understand other people's C# code snippets, and reproducing them yourself from scratch. This means that you'll encounter lots of stuff you need to look up and learn in order to understand to see what those snippets are doing.

The good news is that, both in C# and VB.Net, the .NET framework does most of the heavy lifting, so you'll probably understand and recognize those parts. I use both C# and VB.Net in my job and I've come to realize that, because of the shared framework, the languages aren't that different from each other in practice.

I still like C# better, since I feel it results in cleaner code, somehow.

cfern