tags:

views:

83

answers:

4

What are some of the best books/approaches to learn .NET for a legacy VC++ 6.0 developer? I am hesitant to learn a new language like C# or VB.NET for various reasons. I am experienced in C++/Win32 programming. I am more inclined towards learning C++/CLI to get hands on .NET development experience. Is this a good approach? What did you do to make the .NET plunge? Did you have to learn C# or VB? I am also planning on getting one of the following books for the same. Any ideas/thoughts?

  1. encoding=UTF8&ref=sib_dp_bod_toc&page=5#reader">http://www.amazon.com/reader/1430210532?encoding=UTF8&ref=sib_dp_bod_toc&page=5#reader
  2. http://www.amazon.com/Foundations-CLI-Visual-Language-Experts/dp/1430210230/ref=pd_bxgy_b_text_b
+3  A: 

If you want to use .NET with your programs, you're probably better off learning C# instead. Through macros and custom operator definitions, C++/CLI really is an entirely new language.

C++/CLI is best for native-library interop scenarios that are too complex for C#/pinvoke to handle.

Some interesting things about making the transition from C++ to C#:

  1. It's managed code, so you don't have to delete your pointers.
  2. In C++, you can chose to instantiate a type on the stack or on the heap depending on how you declare the type. In C#, whether a type is instantiated on the stack or the heap depends on the type itself, rather than how you declare it: if a type derives from ValueType, the runtime instantiates the type on the stack. If the type does not derive from ValueType, the runtime instantiates the type on the heap.
  3. In C++, a struct and a class are analogous, the difference being only the default visibility of members (structs are public by default, classes are private by default). In C#, a struct is a ValueType and has special rules, like no inheritance.
  4. In C++, you have multiple inheritance; in C#, you have single inheritance and the ability to inherit from interfaces. Interfaces in C# are (essentially) pure abstract types in C++.

There's more, but those are some of the common gotchas. Here's a good article with more info.

Randolpho
#2 isn't 100% true, but it gets the general idea out there.
Joel Coehoorn
Finalizer vs destructor is probably worth a mention, too.
Joel Coehoorn
+3  A: 

Do not fear C#. As a former C++ programmer (and I think you will find this is the case for most), I found the transition to C# to be very comfortable. Your way of thinking (if you will) will translate quite well with just a few modifications. There are some quirks with the language, but as we have gone from C#1 to C#3, things have gotten even closer to the way a C++ developer might look at the world (generics for example). I would check out the virtual labs on C#. They are pretty decent and let you get your hands on the language quickly.

JP Alioto
A: 

A nice thing that makes c# easier to learn than Win32 programming from C++ is that the type checking is very strong - much more so than C++. So once the compiler is OK with you calling a something with a bunch of parameters, you know that they are of the right type. This was a big struggle for me with Win32, and it was nice not having to repeat that struggle.

Matthias Wandel
A: 

I think the books you're considering are not very good... They try to cover too much and I don't think much will be useful.

There is a short easy book "C# Text Manipulation Handbook" that will get you used to the basic syntax of the language, and teach you some useful string processing libraries that you will use over and over. Then you should grab a book that teaches the latest language features, which are usually covered by books on LINQ (like LINQ in Action). Both those books are short but full of good stuff.

After that, you're going to want to grab books that are specific to a particular type of application (WPF, WinForms, ASP.NET, etc). This should include using ADO.NET to access databases from that application type.

I did C/C++ Win32 development for every 5 years, at this point I don't even think about going back. I can get so much more done with using the .Net platform.

Frank Schwieterman