(1), C # each question mark (?) in the syntax (?) Operator refers:It can be a null type.
The above description on msdn:
When processing the data type of the database and other elements that contain non-assigned valuesNullAssignedValue TypeOrBooleanAndDate typeIs particularly useful. For example, a Boolean field in a database can store values.TrueOrFalseOr, this field can be undefined.
(2), C # Two question marks (?) in the syntax (??) Operator refersNull merge OperatorThe merge operator defines a default value for type conversion to prevent null values of the null type.
The above description on msdn:
??An operator is a null merge operator that defines the types that can be null values and the default values of reference types.If the left operand of this operator is not null, this operator returns the left operand (left expression); otherwise, when the left operand is null, the right operand (right expression) is returned ).
C # code:
Int? X =Null;// Define a variable of the null type
Int? Y = x ?? 1000;// Use the merge operator. If the variable X is null, the default value is 1000.
Console. writeline (Y. tostring ());// 1000
/// <Summary>
/// Gets a single instance
/// </Summary>
Public static log loginstance
{
Get
{
Return _ log ?? (_ Log = new log (); // If the left operand of this operator is not null, this operator returns the left operand; otherwise, the right operand is returned.
}
}