title: Nullable<T> implementation
body: <p>I am trying to implement Nullable type. But below mentioned code doesn't support null value for valuetype datatypes.</p>
  
  <pre><code>using System;
  using System.Runtime;
  using System.Runtime.InteropServices;
  
  namespace Nullable
  {
  
      [Serializable, StructLayout(LayoutKind.Sequential)]    
      public struct Nullable&lt;T&gt; where T : struct
      {
          private bool hasValue;
  
          public bool HasValue
          {
              get { return hasValue; }
          }
  
          internal T value;
  
          public Nullable(T value)
          {
              this.value = value;
              this.hasValue = true;
          }
  
          public T Value
          {
              get
              {
                  if (!this.hasValue)
                  {
                      new InvalidOperationException("No value assigned");
                  }
                  return this.value;
              }
          }
  
          public T GetValueOrDefault()
          {
              return this.value;
          }
  
          public T GetValueOrDefault(T defaultValue)
          {
              if (!this.HasValue)
              {
                  return defaultValue;
              }
              return this.value;
  
          }
  
          public override bool Equals(object obj)
          {
              if (!this.HasValue)
              {
                  return obj == null;
              }
              if (obj == null)
              {
                  return false;
              }
              return this.value.Equals(obj);
          }
  
          public override int GetHashCode()
          {
              if (!this.hasValue)
              {
                  return 0;
              }
              return this.value.GetHashCode();
          }
  
          public override string ToString()
          {
              if (!this.hasValue)
              {
                  return string.Empty;
              }
              return this.value.ToString();
          }
  
          public static implicit operator Nullable&lt;T&gt;(T value)
          {
              return new Nullable&lt;T&gt;(value);
          }
  
          public static explicit operator T(Nullable&lt;T&gt; value)
          {
              return value.Value;
          }
      }
  }
  </code></pre>
  
  <p>When I trying to assign the value as null, it's throwing an error "Cannot convert null to 'Nullable.Nullable' because it is a non-nullable value type"</p>
  
  <p>What I have to do to resolve this issue?</p>