Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I want to learn the C# language and I was wondering if prior knowledge of C++ would make it easier to learn? I have a large background in Java and am currently programming in (and therefore constantly improving on) C++. Would knowledge about the C++ syntax and structure help me understand C# more quickly, or is C# more akin to Java?

share|improve this question

migrated from stackoverflow.com May 6 '11 at 8:29

This question came from our site for professional and enthusiast programmers.

If you know how to think like an OO programmer, it shouldn't be very difficult. –  PostMan May 6 '11 at 7:56
If you know how to avoid thinking like an OO programmer, it would be even simpler. –  SK-logic May 6 '11 at 9:58
@SK-Logic, why? –  StuperUser May 6 '11 at 10:52
@StuperUser, C++ is a multiparadigm language. Do you see any of the OO ideology in STL? In Boost? There is almost nothing OOP-ish in the mscorlib.dll as well. OO is dangerous because it is limited and limiting, and all the OO zealots keep repeating that this limited way of thinking is applicable to everything. One must understand its limits and apply OO only when necessary (and that kind of cases are extremely rare in practice). –  SK-logic May 6 '11 at 12:35
@SK-logic: Then how do you define "OO ideology"? I have - obviously incorrectly - assumed it meant packaging related data and behaviour into objects, utilising the principals of "Inheritance, Encapsulation & Polymorphism" while doing so, where the end goal is to build software solutions. –  Binary Worrier May 6 '11 at 13:35

9 Answers 9

Short answer: Yes

Long answer . . .
C# is more like Java, it is only like C++ in the way Java is like C++.

Especially with regards to memory management, both C# and Java use garbage collection, C++ does not.

Like C++ C# will let you into the bowels of the machine, you can do your own memory management if you really want to (but it's not advised, and rarely needed - in almost 10 years developing on .Net I've never needed it).

However C# has the using keyword for deterministic clean up for objects (but not deterministic memory management, unless you're writing unsafe code), so you can do RAII in C# (not sure about Java).

However C# has diverged from it's Java like roots, with better support for Generics, lambda calculus and variance on generic types. So in that respect it's feature list is more like C++ than Java.

However, syntax wise, it's still more like Java.

That said, the underlying libraries (i.e. the .Net Framework) are very different from what you will find for either C++ or Java, and this will be your largest learning curve, however, it's quite a gentle curve and well worth it, as the framework is incredibly rich and is a joy to use.

Hope this helps.

share|improve this answer
Thanks for the extensive answer. What I have gathered from your answer and the other answers here, C# is more like Java than like C++. This is good news since I actually am more proficient in Java than C++! –  phuibers May 6 '11 at 8:09
@phulbers: It might be more accurate to say that C# is more like Java, but incorporates more things from C++. If you know Java and C++, you already know a lot of C# concepts. –  David Thornley May 6 '11 at 13:54
@Rein Henrichs: Are you missing a </humor> tag there? C# is not Java, indeed from C# 1.0 it benefited from the lessons learned, it has since far outpaced Java as a language (I don't include the JVM in that, just the language, I don't want to start a "JVM runs everywhere" holy war). –  Binary Worrier May 6 '11 at 16:41
I'm not saying C# == Java. I'm saying that's why it's called C#. –  Rein Henrichs May 6 '11 at 16:57

C++ -> C#: What You Need to Know to Move from C++ to C#
C# for C++ Developers

share|improve this answer
Thanks for the useful links. I'll be sure to check them out. –  phuibers May 6 '11 at 8:06

c# is much closer to Java than to c++.

It will be fairly easy to transition to C# from Java as they are both managed languages and you don't (generally) need to worry about memory management like you would have to with C++.

The syntax of C# is similar to Java, the main differences are that you would have to learn the differences in the libraries for doign common functionality, like file access.

There are also some 'gotchas' to watch out for

share|improve this answer

IMHO, the main problem when learning any new language is not the syntax but the class library, i.e. how you do things...
Learning the syntax is a matter of days. Learning the class library a matter of months and years.

share|improve this answer
They syntax is easy. The language concepts may not be. It took me years to become really proficient in object-oriented design and programming, for example, and I couldn't consider myself a first-rate C++ or Java programmer without that. –  David Thornley May 6 '11 at 13:57

If you want to learn C#, start developing in C#.

A lot of the useful effort will go to learning the .NET framework rather than the syntax, which will seem familiar with your knowledge from Java.

Have a look at C# in Depth which should keep you entertained and educated for a few years while you're learning.

share|improve this answer

With respect to learning C#, C++ will hardly add anything to Java (without adding junk, like low level pointy stuff, with it). Beyond the superficial syntactic similarities , C# and C++ models are worlds apart.

share|improve this answer
The OP is working in C++. I wouldn't recommend learning C++ just as a prerequisite to another language, but that's not the question here. –  David Thornley May 6 '11 at 13:55
O ... thanks for the correction. I refine my answer –  explorest May 7 '11 at 8:10

A couple of articles on the topic from MSDN:

C# for Java Developers

C# for C++ Developers

share|improve this answer

No. If your intention is to only learn C# and you think of C++ as a beginners guide to C# you are wrong. C# is a lot more simpler than C++ in terms of refrences and (absense of)pointers. You will first learn C++ and its associated dangers and then learn how to "solve them" in C#.You will first learn what a "friend" is in C++ and then learn that it isnt present in c#. Then you will want to wonder why it wasnt included in C# . Save yourself the trouble and learn C# directly

share|improve this answer
lol, so don't learn C++ because when you go to C# you'll keep on thinking 'I wish I could use friend, multiple interitance, templates etc' and get annoyed at the limitations. Nice answer :) –  gbjbaanb May 6 '11 at 13:24

It certainly helps as the syntax is very similar. This is very superficial, however.

You may be doing things the c++ way which is not idiomatic c# (say if(null == obj), which is fine in c#, but does nothing over if(obj == null).

You will need to remember that you don't have control over memory allocations and shouldn't use pointers...

Visual Studio and IntelliSense help a lot with learning the difference in syntax, it's the different philosophy (GC language) you need to keep in mind.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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