C# 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. It also has "Explicit Member Implementation" which allows a class to specifically implement methods of an interface, separate to its own class methods, or to provide different implementations for two methods with the same name and signature inherited from two base interfaces.
Java does not include operator overloading in order to prevent abuse of the feature, and to keep the language simple.[7] C# allows operator overloading (subject to certain restrictions to ensure logical coherence), which, when used carefully, can make code succinct and more readable.
C# includes indexers which can be considered a special case of operator overloading (like C++ operator[]), or parametrized get/setproperties. An indexer is a property named this[] which uses one or more parameters (indexes); the indices can be objects of any type:
myList[4] = 5;string name = xmlNode.Attributes["name"];orders = customerMap[theCustomer];Java does not include indexers. The common Java pattern is to write explicit get_ and set_ methods where a C# programmer would use an indexer

0 Comments:
Post a Comment