Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1.     public struct Maybe<T> : IEquatable<Maybe<T>> {
  2.         private T value;
  3.         private bool has_value;
  4.         private static bool _isnullable = typeof(T).IsNullable();
  5.  
  6.         public Maybe (T value)
  7.         {
  8.             if (value == null)
  9.             {
  10.                 if (!_isnullable)
  11.                 {
  12.                     throw new ArgumentNullException("value");
  13.                 }
  14.             }
  15.  
  16.             this.value = value;
  17.             has_value  = true;
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement