title: Comparing two structs using ==
body: <p>I am trying to compare two structs using equals (==) in C#. My struct is below:</p>
  
  <pre><code>public struct CisSettings : IEquatable&lt;CisSettings&gt;
  {
      public int Gain { get; private set; }
      public int Offset { get; private set; }
      public int Bright { get; private set; }
      public int Contrast { get; private set; }
  
      public CisSettings(int gain, int offset, int bright, int contrast) : this()
      {
          Gain = gain;
          Offset = offset;
          Bright = bright;
          Contrast = contrast;
      }
  
      public bool Equals(CisSettings other)
      {
          return Equals(other, this);
      }
  
      public override bool Equals(object obj)
      {
          if (obj == null || GetType() != obj.GetType())
          {
              return false;
          }
  
          var objectToCompareWith = (CisSettings) obj;
  
          return objectToCompareWith.Bright == Bright &amp;&amp; objectToCompareWith.Contrast == Contrast &amp;&amp;
                 objectToCompareWith.Gain == Gain &amp;&amp; objectToCompareWith.Offset == Offset;
  
      }
  
      public override int GetHashCode()
      {
          var calculation = Gain + Offset + Bright + Contrast;
          return calculation.GetHashCode();
      }
  }
  </code></pre>
  
  <p>I am trying to have struct as a property in my class, and want to check to see if the struct is equal to the value I am trying to assign it to, before I go ahead and do so, so I am not indicating the property has changed when it hasn't, like so:</p>
  
  <pre><code>public CisSettings TopCisSettings
  {
      get { return _topCisSettings; }
      set
      {
          if (_topCisSettings == value)
          {
              return;
          }
          _topCisSettings = value;
          OnPropertyChanged("TopCisSettings");
      }
  }
  </code></pre>
  
  <p>However, on the line where I check for equality, I get this error:</p>
  
  <blockquote>
    <p>Operator '==' cannot be applied to operands of type 'CisSettings' and
    'CisSettings'</p>
  </blockquote>
  
  <p>I can't figure out why this is happening, could somebody point me in the right direction?</p>