title: Strongly typed Guid as generic struct
body: <p>I already make twice same bug in code like following:</p>
  
  <pre><code>void Foo(Guid appId, Guid accountId, Guid paymentId, Guid whateverId)
  {
  ...
  }
  
  Guid appId = ....;
  Guid accountId = ...;
  Guid paymentId = ...;
  Guid whateverId =....;
  
  //BUG - parameters are swapped - but compiler compiles it
  Foo(appId, paymentId, accountId, whateverId);
  </code></pre>
  
  <p>OK, I want to prevent these bugs, so I created strongly typed GUIDs:</p>
  
  <pre><code>[ImmutableObject(true)]
  public struct AppId
  {
      private readonly Guid _value;
  
      public AppId(string value)
      {            
          var val = Guid.Parse(value);
          CheckValue(val);
          _value = val;
      }      
  
      public AppId(Guid value)
      {
          CheckValue(value);
          _value = value;           
      }
  
      private static void CheckValue(Guid value)
      {
          if(value == Guid.Empty)
              throw new ArgumentException("Guid value cannot be empty", nameof(value));
      }
  
      public override string ToString()
      {
          return _value.ToString();
      }
  }
  </code></pre>
  
  <p>And another one for PaymentId:</p>
  
  <pre><code>[ImmutableObject(true)]
  public struct PaymentId
  {
      private readonly Guid _value;
  
      public PaymentId(string value)
      {            
          var val = Guid.Parse(value);
          CheckValue(val);
          _value = val;
      }      
  
      public PaymentId(Guid value)
      {
          CheckValue(value);
          _value = value;           
      }
  
      private static void CheckValue(Guid value)
      {
          if(value == Guid.Empty)
              throw new ArgumentException("Guid value cannot be empty", nameof(value));
      }
  
      public override string ToString()
      {
          return _value.ToString();
      }
  }
  </code></pre>
  
  <p>These structs are almost same, there is a lot of duplication of code. Isn't is?</p>
  
  <p>I cannot figure out any elegant way to solve it except using class instead of struct. I would rather use struct, because of null checks, less memory footprint, no garbage collector overhead etc...</p>
  
  <p>Do you have some idea how to use struct without duplicating code?</p>