Page 165 - CSharp/C#
P. 165
// assigning a signed long to its maximum value (note the long postfix)
long l = 9223372036854775807L;
It is also possible to make these types nullable, meaning that additionally to the usual values, null
can be assigned, too. If a variable of a nullable type is not initialized, it will be null instead of 0.
Nullable types are marked by adding a question mark (?) after the type.
int a; //This is now 0.
int? b; //This is now null.
Value type - ushort, uint, ulong (unsigned 16 bit, 32 bit, 64 bit integers)
// assigning an unsigned short to its minimum value
ushort s = 0;
// assigning an unsigned short to its maximum value
ushort s = 65535;
// assigning an unsigned int to its minimum value
uint i = 0;
// assigning an unsigned int to its maximum value
uint i = 4294967295;
// assigning an unsigned long to its minimum value (note the unsigned long postfix)
ulong l = 0UL;
// assigning an unsigned long to its maximum value (note the unsigned long postfix)
ulong l = 18446744073709551615UL;
It is also possible to make these types nullable, meaning that additionally to the usual values, null
can be assigned, too. If a variable of a nullable type is not initialized, it will be null instead of 0.
Nullable types are marked by adding a question mark (?) after the type.
uint a; //This is now 0.
uint? b; //This is now null.
Value type - bool
// default value of boolean is false
bool b;
//default value of nullable boolean is null
bool? z;
b = true;
if(b) {
Console.WriteLine("Boolean has true value");
}
The bool keyword is an alias of System.Boolean. It is used to declare variables to store the
Boolean values, true and false.
https://riptutorial.com/ 111

