There are many similarities between C # and Java, but there are some differences. Just went to the library this afternoon to borrow a C # introductory book, in a simple introduction, I learned a few differences:
1. There are only 8 basic data types in Java, data types do not have unsigned and signed distinctions, and basic data types in C # are redundant in Java because numeric values in C # have signed and unsigned types.
2. There are structural types in C #, which should be borrowed from the concept of structs in C/s + +. There is no such data type in Java.
3. In terms of the use of arrays, C # 's multidimensional arrays are declared in particular, by adding commas in brackets after the array name and specifying the length of each dimension when initializing. When you declare a multidimensional array, such as Java or C + +, the array name is followed by a number of brackets.
4. In the control structure, C # adds the foreach statement result to C + +, somewhat similar to the for loop iteration in Java, but I feel that the for iteration function in Java is more powerful. Goto end Sentence in C # I saw it for the first time, and I thought it was special.
Parameter type of the method
Value passing and reference passing: When a method is called, the program first passes the value of the argument to the corresponding parameter, the argument and the shape delegate to the same object for the arguments of the reference type, and for the parameter of the value type, the value of the argument is assigned a copy to the formal parameter. C # Provides reference passing methods for method parameters, which are decorated with the "ref" keyword by referring to passed method parameters:
public static void function (ref int x,ref int y) {}
The REF keyword is also required to be added before the argument is called
Output type parameter:
The output type parameter is decorated with the Out keyword. The output parameter is also referenced by reference, but the formal parameter must be assigned in the method.
Public decimal gain (decimal x, int n, out decimal interest) {}
Array-type parameters:
The parameter type of the method can be an array, and with the params in front of the parameter, the parameter becomes an array-type parameter, analogous to the mutable parameter in Java.
The first lesson of C # Learning