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 don't know much about C# but I've been programming in Java for a few months now. I had always heard what C and C++ were, but was a little curious about where C# came from. I'm a little confused about the C# language since even though it's one of the 'C' languages (C, C++, C#), on the other hand all of my professors seem to line it up against Java, and not the others.

If anyone can clarify that would be great :)

share|improve this question
By any chance, have you looked at: en.wikipedia.org/wiki/C_Sharp_(programming_language) ? –  Lionel Oct 25 '11 at 1:10
Thank you!! That was very helpful :) –  Kaitlyn Mcmordie Oct 25 '11 at 1:14
Just to quote a friend of mine, which is C# dev and teacher when asking him about C# : « you know java ? Then just change the compiler and it should work just fine ». He was obviously ironic, but wanted to emphasis how similar the 2 plateforms are. –  deadalnix Oct 25 '11 at 7:55

2 Answers 2

up vote 6 down vote accepted

Probably because Java and C# are extremely similar: They are both class-based OOP languages with single inheritance and interfaces, strong static typing, garbage collection built into the language, copy semantics that bind to types (value types vs. reference types), generics, namespace hierarchies, reflection, and they both run on a virtualized environment (JRE / .NET runtime). They also share a large part of their syntax.

The other languages from the "C-like" family are different from both Java and C# in many regards: C doesn't have classes, it is weakly-typed, it does not have garbage collection, copy semantics are explicit on use, it compiles directly to machine code, and it lacks generics (offering C Preprocessor macros and implicit casts instead). C++ does have classes, but uses multiple inheritance instead of interfaces; it also offers templates, which are superficially similar to generics but work differently under the hood; it is similar to C in most other regards. Javascript, also very similar to C in its syntax, shares garbage collection and a virtualized environment with Java and C#, but it uses dynamic typing, prototype-based OOP, and it does not use the half-way compilation approach of Java and C#.

share|improve this answer
I'm not sure you can compare java primitives to C# value-types.. –  MattDavey Oct 25 '11 at 10:52
@MattDavey: They behave pretty much the same, except that C# lets you define your own value types, beyond the built-in primitives, whereas in Java, all user-defined classes are automatically reference types. Other than that, the mechanisms are the same. –  tdammers Oct 25 '11 at 12:08
sounds like you have a broader range of experience across the languages so I will defer to your expertise :) –  MattDavey Oct 25 '11 at 13:02

C# is a managed code (compiled to bytecode and run on a virtual machine) language developed by Microsoft to serve as one of the core languages of the .NET framework. It features garbage collection and easy integration with other languages.

It gets lined up with Java because has most of the same features, a C like syntax, managed code execution model, and an automatic garbage collector. It's also an "easy" Object Oriented Language.

It resulted from an effort by Microsoft to develop a VM for Java until Sun sued them over it. Thus that project was shelved and the .NET project took over as Microsoft's effort to do a managed code environment mainly aimed at desktop applications.

You can write a lot of things in C# and run them in a fair number of places now with the Mono framework but it still lacks the shear power of C or C++ as well as being substantially harder to massacre your ambiguously owned cloned feet.

Anything that uses the XNA framework was likely written at least in part in C#.

share|improve this answer
Thank you very much! –  Kaitlyn Mcmordie Oct 25 '11 at 1:17
@WorldEngineer Can you provide some references for It resulted from an effort by Microsoft to develop a VM for Java until Sun sued them over it.? I think you are confusing VisualJ++ with C#. –  Yannis Rizos Oct 25 '11 at 7:28
What does it means as well as being substantially harder to massacre your ambiguously owned cloned feet? Is this against C++ or against C#? –  xanatos Oct 25 '11 at 7:46
@YannisRizos C# was what Microsoft did when they weren't allowed to embrace and extend Java. –  user1249 Oct 25 '11 at 7:49
@xanatos C++ - it's an old joke about multiple inheritance and so forth. The original goes along the lines of C: Shoot yourself in the foot. C++: Make 10 copies of the foot, shoot all of them at random. Got to a hospital where they can't figure out which feet to treat as some are alias for others. –  World Engineer Oct 25 '11 at 7:52

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.