title: C# - Good way to expose Nullable<T> to COM
body: <p>We are working on exposing an assembly to COM.</p>
  
  <p>Among other things, we frequency use nullable values such as long?, DateTime?, etc.  These are generic types and can't be exposed to COM.</p>
  
  <p>What is a good substitute for these data types for COM?</p>
  
  <p>We have tried the following:</p>
  
  <pre><code>//Original CustomerID property in class
  public long? CustomerID
  {
     get;
     set;
  }
  
  //Explicit COM interface
  long IComInterface.CustomerID
  {
    get { return CustomerID.GetValueOrDefault(); }
    set { CustomerID = value; }
  }
  </code></pre>
  
  <p>The problem is, we need a way to pass "null" back and forth through COM.  Using a number like -1 or 0 won't work because these are valid values as well.</p>
  
  <p>We are having to use nullables b/c these originally came from our database schema.</p>