Back to slide -- Keyboard shortcut: 'u'                      generics/nullable/nullable.cs - A partial reproduction of struct Nullable<T>.Lecture 11 - slide 13 : 21
Program 1

using System;

public struct Nullable<T> 
  where T : struct{

  private T value;
  private bool hasValue;

  public Nullable(T value){
    this.value = value;
    this.hasValue = true;
  }

  public bool HasValue{
    get{
      return hasValue;
    }
  }

  public T Value{
    get{
      if(hasValue)
        return value;
      else throw new InvalidOperationException();
    }
  }

}