Advantages of C# Over Java


In my company there is many teams like Java team ,.Net Team ,testing team and so on and between us there is always one contest that is which language is better C# or Java and during this contest I have found some interesting advantages of C# over Java and for that I have also won the prize from Java team...!!.

So I want to share it to all people so other can also know about it.

  • C# being a .NET language, supports language interoperability, i.e. C# can access code written in any .NET compliant language and can also inherit the classes written in these languages. This is not possible in Java.
  • The code written in C#, on compilation generates an ‘.exe' or ‘.dll' file which is also called Portable Executable file. These files contain MSIL (Microsoft Intermediate Language) code. As against this, the Java code on compilation generates a ‘.class' file, which contains bytecode. 
  • The portable executable file of C# can contain any number of classes, whereas, the ‘.class' file in Java contains only one class.
  • The methods in C# are not virtual by default. On the contrary, methods in Java are virtual by default, which degrades the performance.
  • The classes in C# are grouped in Namespaces, whereas, classes in Java are grouped in Packages.
  • The C# namespaces are not related to the directories. The packages in Java are directly related with the directory names.
  • The variables of primitive data types in C# are more powerful. This is because even though they are not objects functions can be called using them. The variables of primitive data types in Java cannot call functions.
  • C# has features like Properties and Indexers. These features are not available in the Java language.
  • C# supports Structures, Operator Overloading and Preprocessors directives, whereas, Java has none of them.
  • Through C# we can easily call Windows API function and access COM components which is quite difficult in Java.


I hope you understand some advantages of C# over java also I am preparing big article on this topic, you will see it soon, if you know something about it,then share with me.

Next Recommended Reading Difference between C# and Java