12

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#.

4
  • 16
    "I swear it is easier to translate English to Latin than VB to C#." You've got to be kidding. The translation between VB.Net & C# is practically literal. c# has semi-colons and brackets around blocks, vb has End XXX instead. Function call syntax is identical in mos usages and they both rely on the same BCL. I just find it odd you are having so much trouble with a few semi-colons. Aug 5, 2010 at 14:30
  • 2
    You built a career on C/C++, that should give you a leg up onto C#. My policy is that if I want to become an expert at something, I will immerse myself in that environment for 6 months, 24-7. After 6 months, if I am not comfortable with the "expert" title, do something else. Things will seem frustrating, but believe it or not you will get used to it. Everytime I buy a cell phone, I am frusttrated at how to use it. After 6 months of using the phone everyday, I can use it with my eyes closed. Ta DAA !!! Expert!!
    – user279521
    Aug 5, 2010 at 14:43
  • I have been working a lot with LINQ lately and trying also to learn that, I have always used SProcs to control data retrieval but Silverlight 4 Business Applications seem to prefer LINQ over SProcs. My point being that alot of the inline statements I have been looking at were inline LINQ lambda examples and trying to find VB.Net LINQ examples is near impossible so I have been trying to convert those C# examples to VB.Net LINQ, which prompted the English to Latin comment.
    – Stryder
    Aug 5, 2010 at 16:04
  • 1
    This question appears to be off-topic because it is should belong to programmers.stackexchange
    – nawfal
    Jul 3, 2014 at 10:21

13 Answers 13

14

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#.

3
  • That will teach the very basics of the syntax, but completely miss C# idioms. Aug 5, 2010 at 14:26
  • 2
    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#
    – Iain Ward
    Aug 5, 2010 at 14:32
  • 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.
    – Stryder
    Aug 5, 2010 at 16:01
4

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.

5
  • 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. Aug 5, 2010 at 15:37
  • @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. Aug 5, 2010 at 15:40
  • Thank you for the book reference and link to Project Euler I have never come across that before.
    – Stryder
    Aug 5, 2010 at 16:06
  • The Project Euler site is interesting. I never knew something like that existed outside Google's CodeJam and TopCoder. Aug 9, 2010 at 15:38
  • @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. Aug 9, 2010 at 15:54
2

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

3
  • 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.
    – Stryder
    Aug 5, 2010 at 16:08
  • 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. I will edit my answer with some links about LINQ. The 101 VB.Net LINQ samples on MSDN are useful, I also liked the coverage in the book Programming VB2008
    – MarkJ
    Aug 5, 2010 at 16:22
  • +1 for the link What VB developers should know about C# and all of the other great links.
    – Todd Main
    Aug 6, 2010 at 13:36
1

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

1
  • Thank you for the book reference!
    – Stryder
    Aug 5, 2010 at 16:06
0

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.

1
  • 1
    They are usually pretty complex examples, though. I don't see someone who's having trouble reading basic C# making much headway with those.
    – Adam Lear
    Aug 5, 2010 at 14:43
0

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.

0

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#.

0

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.

0

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.

0

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.

0

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.

0

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.