// Nullable data field.
public int? numericValue = null;
public bool? boolValue = true;
// Note the nullable return type.
public int? GetIntFromDatabase()
{ return numericValue; }
// Note the nullable return type.
public bool? GetBoolFromDatabase()
{ return boolValue; }
}
Now, assume the following Main() method, which invokes each member of the DatabaseReader
class, and discovers the assigned values using the HasValue and Value members as well as using the
C# equality operator (not-equal, to be exact):
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Nullable Data *****\n");
DatabaseReader dr = new DatabaseReader();
Do'stlaringiz bilan baham: |