Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C#(Visual Studio 20 10。 NET Framework 4)“Guid?” What does the question mark mean?
C#(Visual Studio 20 10。 NET Framework 4)“Guid?” What does the question mark mean?
Nullable type modifier "t?" .

The base type of nullable type can be any nullable value type or any type parameter with structural constraints, but it cannot be nullable type or reference type. For example: int? Represents plastic that can be empty, and int? Is an invalid type. In other words, an empty type can represent all the values of its underlying type and an extra empty value. Grammar t? It's short for System.Nullable. Nullable types have a HasValue. Read-only Bool property of. When this property of an instance of nullable type is true, it means that the instance is not empty and contains known values; When HasValue is false, accessing the Value property will cause the system. InvalidOperationException。 Nullable type t? A public constructor with only one parameter of type T, such as new int? (123) will get an int with a value of 123? Type instance. From t? There is a boxing conversion for any interface implemented by T, and there is a boxing conversion for any interface implemented by T? The unpacking transformation is based on. However, nullable types do not satisfy the interface constraints under any circumstances, even if the underlying type implements a specific interface.

For example:

class Class 1

{

int? a = 0;

int b;

Public class 1 ()

{

A = empty; //Compiled through

B = empty; //Compilation failed

}

}