Features of C# absent in Java
- C# includes more primitive types and the functionality to catch arithmetic exceptions.
- Includes a large number of notational conveniences over Java, many of which, such as operator overloading and user-defined casts, are already familiar to the large community of C++ programmers.
- Event handling is a "first class citizen"; it is part of the language itself.
- Allows the definition of "structs", that are similar to classes but may be allocated on the stack (unlike instances of classes in C# and Java).
- C# implements properties as part of the language syntax.
- C# allows switch statements to operate on strings.
- C# allows Anonymous methods providing closure functionality.
- C# allows iterators that employ co-routines via a functional-style yield keyword.
- C# has support for output parameters, aiding in the return of multiple values, a featured shared by C++ and SQL.
- C# has the ability to alias namespaces.
- C# has "Explicit Member Implementation" that allows a class to specifically implement methods of an interface, separate to its own class methods. This allows it also to implement two different interfaces that happen to have a method of the same name. The methods of an interface do not need to be "public"; they can be made to be accessible only via that interface.
- C# provides integration with COM.
- Following the example of C and C++, C# allows call by reference for primitive and reference types.
Features of Java absent in C#
- Java's strictfp keyword guarantees the result of floating point operations remain the same across platforms.
- Java supports checked exceptions for better enforcement of error trapping and handling.
Philosophical differences between the languages
Sam HobbsPosted Dec 9, 2013, 4:02 PM
Also,, welcome to C# Corner.
Sam HobbsPosted Dec 9, 2013, 2:57 PM
Also note that the Common Language Infrastructure (CLI), used by C#, supports multiple languages whereas the Java Virtual Machine, used by Java, only supports Java.
Sam HobbsPosted Dec 9, 2013, 1:57 PM
Yes, thank you Ghulam. I am also interested in knowing what primitive types C# has that Java does not. Note that stacks are machine-dependent; not all processes have stacks. That might why stacks are excluded from the Java Virtual Machine that is designed to be portable. Also, what is the "C# API"?
Mahesh ChandPosted Dec 9, 2013, 12:00 PM
Very interesting. Thank you for share, Ghulam.