5

I am looking to switch to C#. I come from a C / C++ background but C# is a little different for me. I am switching mainly because of Silverlight and MVVM; all examples are in C#. Any information is in C# and I am confused when I read through it all.

What is a good place to start learning C# when starting with existing C / C++ knowledge?

Daniel Imms
  • 47,944
  • 19
  • 150
  • 166
Rico
  • 1,258
  • 4
  • 17
  • 35
  • No i simply want to become c# intelligent. When i look through c# examples a lot of the base code seems hidden. which is fine but i figure if i start at square 1 i can sprint to the end – Rico Jan 13 '10 at 19:05
  • Duplicate: http://stackoverflow.com/questions/287927/best-way-to-learn-c – gnovice Jan 13 '10 at 19:19

6 Answers6

17

Start writing code in C# ASAP. Only way to learn the language is to write it. You already understand VB.NET. You've got a huge lead on anyone new to .NET.

Take a smallish application you've written in VB.NET and methodically change it over to C#.

You'll learn the syntax, etc. quickly.

Write all of your future projects in C#. Just force yourself into the change and you'll do fine.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tad Donaghe
  • 6,625
  • 1
  • 29
  • 64
1

Read the best C# books. :)

Community
  • 1
  • 1
Parappa
  • 7,566
  • 3
  • 34
  • 38
1

Shortly after learning VB.NET I decided I'd rather be coding C#. I learned it by reading a couple of books and working on a project. Slowly, I got my coworkers converted over to the language from VB.NET as well. The languages are very similar, some code conversion is just a matter of changing syntax.

However, if you've ever worked with a true VB'er you will see VB specific functions used in their code that'll make you scratch your head. There are string handling functions and casting functions for example that you will have to convert. Also, C# has no RaiseEvent. Events take a little more effort to understand in C# because you need to wrap your mind around delegates (C++ function pointers/callbacks). As others have said, if you are coming from C++ this shouldn't be too difficult.

Many people go on about needing to work on a project to understand a language, which I agree with. However, there are features of languages which you will never know about if you don't pick up a couple of books and read about them. I've been able to show my coworkers many useful techniques just by reading a couple of books.

Lastly, C# is a great language. I was very skeptical when I first started using .NET, but now I know that MS got the right talent together for that framework and language.

Good luck.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nate
  • 5,237
  • 7
  • 42
  • 52
  • Hey man good reply thanks for the info. I believe a book will have to be read as well :). Especially to implement silverlight and MVVM properly – Rico Jan 13 '10 at 19:41
1

The Wikipedia article "C Sharp (programming language)" is a decent introduction to C# as a language.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

As you know C++ (as you wrote in the question) and VB.Net (as you mentioned in the title), C# won't be hard for you if do know them both well. If this is the case, just grab any source in C#, and read it.

By the way, the article from wikipedia is a very nice intro.

bohdan_trotsenko
  • 5,167
  • 3
  • 43
  • 70
0

One thing that may work for you is to use a converter

  1. Write your desired code in VB.
  2. Paste small pieces of code you don't know how to write in C# into http://converter.telerik.com/ and convert.
  3. Manually type the result into your C# project.

Gradually, reduce your reliance on converter as you become more familiar with language.

That is enough to get you started, however C# has language features that VB does not, or VB offers in a way that is so wordy that no one really uses it.

The more features you will come across as you look at code examples from around the web (like on stack overflow), and you need to either look up syntax or function manually, or convert from C# back to vb to understand what it is doing (use same converter). Or, just paste it in and see what it does.

binderbound
  • 791
  • 1
  • 7
  • 27