Where does null define itself?
null is a keyword. null is not a type.
There are two kinds of variables, each of which has its own set of zeroing rules.
Reference Type Variables
The variable is set and can refer to instances of the same or different types.
//The reference type is System.Object and // the instance type is System.String object s = "123";
With reference variable types, null indicates no instance.
//The reference type is System.Object and // there is no instance. object x = null;
Using a variable of a reference type that does not have an instance will result in the exclusion of a null reference.
string s = null; s = s + "a";
Value type variables
Variables of type value have one type, and assigned values ββmust be of this type and not contain others.
int i = 3;
With some value type variables (only those of type Nullable<T> ), null can be assigned. This indicates a lack of value.
int? i = null;
Using a value type that does not have a value does not throw null reference exceptions - the links are not connected.
int? i = null if (i < 3) //false
Amy b
source share