title: Correct way to create a custom comparer for linq join
body: <p>I have some problems creating a custom comparer to be used in linq.join.
  I'm not very expert in linq, so I probably misunderstood join function behavior.</p>
  
  <p>This is my code. I want to perfor a simple join between those two lists:</p>
  
  <pre><code>List&lt;MyObj&gt; operand1Data = new List&lt;MyObj&gt;()
  {
      new MyObj() { Var = "1var1", Year = 0 },
      new MyObj() { Var = "1var2", Year = 2018 },
  };
  
  List&lt;MyObj&gt; operand2Data = new List&lt;MyObj&gt;()
  {
      new MyObj() { Var = "2var1", Year = 2018 },
      new MyObj() { Var = "2var2", Year = 2019 },
      new MyObj() { Var = "2var3", Year = 2020 },
  };
  
  var result= operand1Data.Join(operand2Data, x =&gt; x.Year, y =&gt; y.Year, (x, y) =&gt; x.Var + y.Var, new TestComparer()).ToList();
  </code></pre>
  
  <p>The problem is that I want 0 to match with every element in the other list, so I came up with this custom comparer:</p>
  
  <pre><code>public class TestComparer : IEqualityComparer&lt;int&gt;
  {
      public bool Equals(int x, int y)
      {
          if (x == 0 || y == 0)
          {
              return true;
          }
          else
          {
              return x.Equals(y);
          }
      }
  
      public int GetHashCode(int obj)
      {
          return 1;
      }
  }
  </code></pre>
  
  <p>This does not work. The result only contains:</p>
  
  <pre><code>"1var12var3"
  "1var22var1"
  </code></pre>
  
  <p>and what I expected was:</p>
  
  <pre><code>"1var12var1"
  "1var12var2"
  "1var12var3"
  "1var22var1"
  </code></pre>
  
  <p>What am I missing? Can someone help me fixing this? Thanks for your help.</p>