The resolution type is followed by question marks and double question marks. The resolution type is followed by question marks.
In the variable definition, the type is followed by a question mark, indicating that the data type is NullAble. When you set an initial value for a variable, assign null to the variable (int type) instead of 0!
Example:
Int? I = 3 is equivalent to Nullable <int> I = new Nullable <int> (3 );
Int? Is another method of writing generic Nullable <int>.
When defining a method, null values can be passed:
Public void AddUser (string name, string password, int? Role) {// content omitted ...} // use AddUser ("Xiao Ming", "123456", null); // The default value of null is unaudited user AddUser ("Xiao Wang", "123456", 1 ); // Postmaster AddUser ("why?", "123456", 2); // common user view plaincopy to clipboardprint? Public void AddUser (string name, string password, int? Role) {// content omitted ...} // use AddUser ("Xiao Ming", "123456", null); // The default value of null is unaudited user AddUser ("Xiao Wang", "123456", 1 ); // Postmaster AddUser ("why?", "123456", 2); // common user
2. There are two question marks after the type in the variable definition. They are used to determine and assign values. First, they determine whether the current variable is null. If yes, they can be assigned a new value. Otherwise, they will be skipped! What does it mean to take the assigned value ?? On the left, if the left is null, the assigned value is used ?? On the right.
Example: page ?? 0 indicates that when page is null, the value on the right is 0.
Recommended: http://www.cnblogs.com/roucheng/p/3562327.html