Type judgment symbol:
C #: object a; if (a is int) {} is judged by the is symbol
Java: object a; if (a instanceof Integer) {} is determined by the instanceof symbol.
Class and interface inheritance:
C #: public class MDataRow: List <MDataCell>, IDataRecord, ICustomTypeDescriptor
Java: public class MDataRow extends ArrayList <MDataCell> implements Set
The similarities are in order, first base class, and then interface.
The Inheritance and Implementation of C # are separated by ":", and ",". Interfaces must start with I.
Java class inheritance uses extends, and the interface implementation uses implements. The interface does not have a specification starting with "I", so it is easy to tell whether it is a class or an interface.
Code specifications and coding habits:
Take a look at the small Java code:
Package Test;
Import java. lang .*;
Publicclass Demo {
Int id;
Publicint getId (){
Return id;
}
Publicvoid setId (int id ){
This. id = id;
}
Public Demo (int id ){
Super ();
This. id = id;
}
Void write (){
System. out. print (id );
}
}
The basic comparison is as follows:
C #: namespace; using; uppercase method letters; base call base class members; Wrap Java: package; import; lowercase method letters; super call base class members; no line breaks in the brackets by default.
C # some additional attributes and Syntax:
Since C # is a language generated after learning Java, C # will have more things than Java. These are irrelevant to each other. It is only mentioned below:
Attribute, enumeration, Delegate, event, unsafe code pointer), override, virtual, new) Operators related to the overload override method, reference passing parameter ref, out), character escape @), etc.
Constant definition:
C #: const string name; or static readonly string name;
Java: final string name;
Today, we have a lot of things.