Click here to Skip to main content
15,883,870 members
Please Sign up or sign in to vote.
1.78/5 (7 votes)
See more:
Hi,all my friends!

I am new coder.
I know C and C++.

My friend told me that C# was better than C++.
So i want to know how to learn C#?
Plz recommend some books or website to me.

And i want to know what's difference between C# and C++?
Or,when to use C#? when to use C++?

BR!
Thank you very much!
Posted
Updated 14-Aug-13 20:50pm
v2
Comments
pasztorpisti 15-Aug-13 6:30am    
Asking for book recommendations is never a good idea. Every book assumes a specified level of knowledge in this and that and it helps you to reach a higher level from that point. Only you can decide whether a book is good for you or not. A book can also start from very beginner level, for example a book can easily contain basic programming related lessons besides C#, I have seen a lot of books of this type. If the starting level of the book is too beginner for you then you will get bored of it quickly. I usually choose the book by running through the table of contents of several books, maybe randomly checking out a few pages from the meaty parts - this is usually enough. When you are about to learn a thick book it is worth investing 1-2 days in choosing the book.

I think "better" is a very vague term. As you indicate it depends on what you need to do. I would say that it is easier to develop many types of applications more quickly and cleanly.

If you know C++, and do good OOP, you should be able to pick up C# relatively quickly. However, the converse is probably not true. C++ is harder to get to grips with, and to write good code. Having said that I have also seen some very bad code in C#.

There are several differences, which I don't think I could do justice here. The one that people always quote is that "C# has no pointers". Well, yes and no. C# uses references to most objects. If you're used to using references in C++ then it's not that difficult to get your head around. However, they are more like pointers in that a reference can be null (by default!) whereas in C++ you have to write some stupid code to end up with a null reference.

As to books, by far and away the best and most useful books I have found, and probably the only two you'll ever need are: CLR via C#[^] and Effective C#[^].

Personally these days I would choose C# over C++ unless it wasn't an option. Practically, off the top of my head, that probably means having to revert to C++:
1) if you're writing an application that you want to use on a system where the CLR/.NET isn't available. (I'm not up to speed with how progress of implementing it on systems other than Windows is going).
2) if you're writing a module that needs to be invoked by another non-CLR application
3) if your module or application will interface heavily with non-CLR code and the overhead of developing the classes to interact with it (through P/Invoke calls) would be too great or overly complicated
4) there may be other reasons (such as writing embedded code?) but I can't think of everything; I'm sure other people will comment to tell me something I've said is wrong :)

Regards,
Ian.
 
Share this answer
 
v2
Comments
pasztorpisti 15-Aug-13 5:16am    
5. CLR via C# is a good book to learn from for a serious C++ programmer. There are a lot of toy books on C# for beginner programmers - those are very boring for an experienced programmer.
I think you should start with Petzold's book. Charles Petzold is a well known author of over fifteen programming books. To many, his books on programming Windows are the definitive books on the subject."Programming Microsoft Windows with C#" [^] is a tutorial for programmers wishing to write applications for Windows using the C# programming language and the Windows Forms class library. C# is a object-oriented programming language based on C, and Windows Forms is part of the Microsoft .NET framework.

"What the C or C++ Programmer Needs to Know About C# and the .NET Framework " is a great book on .NET programming, that you can download free from this page :
http://www.charlespetzold.com/dotnet/index.html[^]

It seems to me, this article will be also interesting to you

Good luck.
Alex.
 
Share this answer
 
Some differences could be mentioned like:
C# is a managed language that runs in a virtual machine. It compiles down to a platform agnostic intermediate code.
C++ creates raw assemblies that run directly on the target platform.
Because C# runs in a virtual machine, memory management is handled automatically. In C++, you must handle memory manually, or write (or acquire) a garbage collection library. However, great strides have gone into making C++ a little easier to use (Auto Pointers, and RAII).
C# does not support multiple inheritance, C++ does.
C# has delegates, which are a powerful alternative to C++'s function pointers and pointers-to-members.
C++ is not, by default, managed. C# is.
C# has syntax for properties and events and so more what would be a never ending topic.
Have a look at..
Difference between C++ and C#[^]

For learning C# do a search in Google[^],you should have tons of links,choose what you like.
But i would suggest you to MSDN[^].

Good Luck
Happy Coding
Shuvro
 
Share this answer
 
Comments
Joezer BH 18-Aug-13 9:06am    
5ed!
ridoy 18-Aug-13 12:14pm    
Thanks Maimonides,:).
there are many good websites for that...some of the good websites are

msdn.microsoft.com
mybringback.com
lynda.com(good but this is not free it needs money)



and codeproject too.... :)

also this is good ebook for learning c# http://kickass.to/microsoft-visual-c-2012-step-by-step-v413hav-t6950732.html[^]

BEST OF LUCK


Regards,
Ahsan Naveed
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900