title: Why can't the operator '==' be applied to a struct and default(struct)?
body: <p>I'm seeing some odd behaviour after using FirstOrDefault() on a collection of structs. I've isolated it into this reproduction case. This program won't compile</p>
  
  <pre><code>using System;
  using System.Linq;
  
  namespace MyProgram {
      public class Program {
          static void Main() {
  
              var users = new User[] {
              new User() { UserGuid = Guid.NewGuid(), Username = "user01" },
              new User() { UserGuid = Guid.NewGuid(), Username = "user02" }
          };
  
              var user = users.FirstOrDefault(u =&gt; u.Username == "user01");
              Console.WriteLine(user == default(User) ? "not found" : "found");
          }
  
      }
  
      public struct User {
          public Guid UserGuid;
          public string Username;
      }
  }
  </code></pre>
  
  <p>The compiler error is the rather cryptic:</p>
  
  <blockquote>
    <p>Operator '==' cannot be applied to operands of type 'MyProgram.User' and 'MyProgram.User' </p>
  </blockquote>
  
  <p>Changing the struct to a class works fine - but I'm at a loss as to why I can't compare a struct 'instance' to a default?</p>