Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, I want to learn C# for a job interview (they want C# or Java, I know Java, but figure knowing both would be good). I already know Java, C++, C, F# and to some extent Python and Pascal.

What are the big differences between C# and Java or C++? What are some good resources to look into, given I want to get a basic understanding in couple of hours?

BTW: I told them that I didn't know C#, saying that I did however know these other languages, and that I could probably pick it up quite quickly.


migration rejected from Apr 25 '15 at 19:41

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by durron597, jwenting, MichaelT, GlenH7, Snowman Apr 25 '15 at 19:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – durron597, jwenting, Community, GlenH7, Snowman
If this question can be reworded to fit the rules in the help center, please edit the question.

It is better to say that you don't know it than assure you do and fail on some trivial question. Honesty - is the best start of business relationships. – zerkms May 20 '11 at 2:37
@zerkms, very good advice! =) – MikeU May 20 '11 at 2:39
@MBU: It would be better if it was written with proper english ))) I see it looks lame, but cannot write the same thoughts in better way. – zerkms May 20 '11 at 2:40
I assume you have about 3 days or there about until the interview. If yes, are not going to learn enough in that time to make a difference. Even if you do, what would you do if they ask you what C# projects you have worked on? Anyone can work on a language but those that have used it in production code can talk about it in interviews. I recommend that you be honest with them as zerkms said. To better your odds, focus on your ability to learn quickly and your passion for languages. – Phil May 20 '11 at 2:58
For closure, I got the job, and they are calling me a "Java developer". The interviewer had forgotten in his question sheet, and so for the explict technical questions (after chatting abit about F#) asked me a couple of questions about programming, avoiding any C# syntax ones since he knew I didn't know it. He hadn't used java in about 6 years, and ended up asking me what is a delegate something which C# has and java doesn't. I suggested possibly and inner class used to delegate some tasks to, and he explained it was like a C function pointer. i was: F# is made of those - continations. – Oxinabox Jun 20 '11 at 10:29
up vote 5 down vote accepted

Since you know F#, another .NET language, you are in a good position for understanding some of the big difference between C# and Java. I know all three languages so I think I can give you a good list of the big differences between C# and Java:

  • C# generics are reified, whereas Java generics are implemented via erasure.
  • C# has a unified object system with extendable ValueTypes (structs) which have copy semantics and may be allocated on the call stack instead of the heap. Java has a fixed set of primitive value types outside of the object hierarchy.
  • C# has delegates supporting first class functions and anonymous lambda expressions including closures. Java may emulate these using anonymous inner classes.
  • C# has built-in "properties" (use them like fields, but with custom get:unit -> 'a and set:'a -> unit implementations given in type definition) including custom index access implementations, Java doesn't.
  • C# has the static dynamic type, which allows you to program against the DLR with syntax which resolves calls at runtime. Java has no analog.
  • C# doesn't enforce class-per-file like Java does. In fact, C# has "partial classes", which allow you to break a class implementation across files (it even has something called "partial methods" which are similar for methods, but I've never used them).
  • C# and .NET in general are not shy about implementing features which are tied to Windows, such as easier native interop and libraries like WinForms which is just a thin wrapper around GDI+. Java takes pains to remain platform agnostic with libraries like Swing which allows you to make GUI apps which can run on Windows, Linux, and Mac for example almost out-of-the-box.

Other differences:

  • C# has LINQ, a built-in query syntax which captures expression trees and allows them to executed by alternative means (a bit like F#'s computation expressions / monads). Java has no analog.
  • C# has operator overloading, Java doesn't.
  • C# has Nullable, which allows you to treat ValueTypes like int which usually can't take on a null value as if they could (e.g. int? x = null). Java has special wrapper types like Integer for int used for boxing and unboxing primitives.
  • C# has local type inference (e.g. var x = 3 instead of int x = 3. Not nearly as aggressive as F#'s type inference, though), Java doesn't.
  • C# has "yield return" syntax which allows you to implement IEnumerables similar to F#'s sequence expressions. In Java you must implement it's Iterable using the full awkward interface.

In many respects, C# is a superset of Java, so you're actually well on the way.

Personally, I'd get a C# reference book (not a book that tries to teach the language, but a complete reference) and start looking for things that aren't familiar. Unfortunately, I'm not in a position to recommend a specific title. What I can say is that I learned VB.Net very quickly using a similar approach. In that case, I read VB.Net in a Nutshell, looking for differences from languages I knew previously.

In the longer term, I'd recommend reading Jon Skeet's book, as it really explains some of the more advanced topics very well.

I wouldn't say C# is a superset of Java. The way Java handles inner classes is a lot more different from how C# handles nested classes and there are also some variations with how native types are handled. – davidk01 May 21 '11 at 21:36
And there are some major differences around generics. – Peter Taylor May 21 '11 at 22:47
+1 at Jon skeet's book, will be great for some language specifics. – Ziv May 21 '11 at 23:46
@davidk01: You're quite right that there are major differences. (Including some important syntax, enums, checked exceptions, the entire framework etc). That is why I didn't say that Java is a subset of Java. I used the expression "in many respects", meaning "to a large extent". – Kramii May 22 '11 at 9:16

I think you made the right call being honest, especially considering the short time frame. Many hiring managers who are trying to fill a C# position will consider someone whose only experience is with Java, especially if it's not a senior level position.

Even if you received an offer, it would probably be several weeks between accepting the job and actually starting. That would at least give you time to run through some programming books to get a better idea of the differences between the two languages.

Here is a good Wikipedia article about the differences between C# and Java:


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