简体   繁体   中英

Linux/C++ programmer to C#/Windows programmer

I have been coding exclusively for a while now on Linux with C++. In my current job, it's a Windows shop with C# as main language. I've retrained myself to use Visual Studio instead of emacs ( main reason is the integrated debugger in VC, emacs mode in VC helps ), setup Cygwin ( since I cannot live without a shell ) and pickup the ropes of managed language. What tools, books, website ( besides MSDN ) or pitfalls do you think I should check to make myself a more efficient Windows/C# coder?

The first things to consider when switching from C++ to C# the fact that mostly share some of the surface syntax, but the difference of programming paradigms gets bigger and bigger as you dig in more into .Net.

Get to know the C# core programming paradigms before starting to program else you might fall in the trap of writing C++ programs in C#, which isn't the best idea by long stretch. The most important things to get accustomed to are:

  • Automatic memory management and garbage collection including the dispose pattern. Learn the basics and pitfalls.
  • What are classes, interfaces, structs and primitives in .Net, and how they behave compared to C++.
  • Events, delegates, properties, lambda expressions all of which are somewhat new concepts when coming from C++.
  • .Net generics and differences between templates.
  • strings, arrays, custom attributes, reflection, exceptions and threading basics in .Net, all of these are heavily used everywhere in .Net, and you must learn their intricacies to use them effectively.
  • GUI programming in Winforms and ASP.Net (and maybe after there WPF), components, controtrols, databinding. The .Net GUI model.

First start with a generic .Net book that introduces you to all of these concepts. I recommend a book over reading tutorials and articles first of all so you can have a big complete picture of .Net at the end. Articles on the internet might not achieve this. Best generic .Net book I've read:

Professional C#, 3rd edition. by Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen

专业C#,第3版,ISBN:978-0-7645-5759-0

And second, since you're from a C++ background, and you are used to working close to the metal and thinking in way that is close to how hardware works (raw memory management (pointers, mem allocations, etc) I can only recommend one book that will really demystify what .Net is and what it does :

CLR Via C# by Jeffrey Richter

CLR通过C#,第二版ISBN 9780735621633

I can't stress enough how good this book is for every .Net developer, especially when coming from C++ and at the same time being one of the best .Net books I've read. The book is a pure pleasure to read and covers topics from :

  • .Net execution model (from MSIL to native code)
  • Memory management (how the .net runtime and garbage collector manages memory, heap layout, memory generations, finalization, large object heap)
  • Designing types
  • Assembly loading, reflection, application domains
  • and many more ...

This is my best advice I could give to anyone on their way to become an expert C# developer in the shortest time possible.

Since you already know how to program in C++, check out:

A Programmers Introduction to C# 2.0 , by Eric Gunnerson and Nick Wienholt

Nice balance between language reference and general .net information.

Similarly: Essential .NET, Volume I: The Common Language Runtime by Don Box and Chris Sells

Really interesting "under the covers" net book (but written for .net version 1 so may be a little out of date).

Read about garbage collection in .Net . People coming from C++ land are used to the explicit memory allocation and management. In C# explicit memory management is virtually non-existing.

Another topic you should check out is the difference between C# generics and C++ templates. I don't have a good link for that one, though.

Depending on the product you are working on, you might have to resort to calling Win32 API functions from C#. This is done through P/Invoke, so you might want to read a bit about it as well. And if you have to actually use it, http://pinvoke.net is very useful collection of C# declarations for most of the Win32 APIs.

You might also want to learn at least the basics of COM, as very often C#/.Net applications choose/need to reuse components from third party vendors, which are often implemented as COM components. COM is a complex topic though. My favorite books on COM and Essential COM by Don Box and Professional DCOM by Roger rimes. I would borrow these from a library, as all you need to read are the first few chapters (unless you want to go in depth).

A basic understanding of windows, messages and message queues is necessary, if you are going to write client applications. You will be using Winforms of WPF/XAML for these, and both technologies do a good job of isolating the details from you; however to be able to write good code you need to know what is going behind the scenes. I am not sure what a good book would be for that, but MSDN has lot of information.

My background was predominantly C/Unix and Python with some java and dusty 2000-vintage VB6 when I first used C#. I was familiar with managed runtimes from the work I had done with Java and the .Net API's have a somewhat similar look-and-feel to earlier MS API's.

I found Troelsen's Pro C# and the .Net 2.0 Platform to be a really good C#/.Net resource. There are more recent editions out now.

Check out petzold's dotnet book zero . This might help.

Get yourself a copy of Resharper . It's probably the single best productivity tool out there for straight up coding.

Shouldn't be the base the CLR? And shouldn't it be unimportant which .NET language is used? If I look through the .NET docs I can decide if I'd like to see the stuff in VB.Net, C# or C++. So if you know C++ why shouldn't you use "managed C++"?

Regards Friedrich

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM