title: Using LINQ, can I verify a property has the same value for all objects?
body: <p>I have a Crate object, which has a List of KeyValuePairs.  Currently, I'm iterating through each pair to see if the kvp.Value.PixelsWide are the same for all items in the List.  If they are, return true, else false.  </p>
  
  <p>The existing method that I have is shown below:</p>
  
  <pre><code>public bool Validate(Crate crate)
      {
          int firstSectionWidth = 0;
          foreach (KeyValuePair&lt;string, SectionConfiguration&gt; kvp in crate.Sections)
          {
              if (firstSectionWidth == 0)//first time in loop
              {
                  firstSectionWidth = kvp.Value.PixelsWide;
              }
              else //not the first time in loop
              {
                  if (kvp.Value.PixelsWide != firstSectionWidth)
                  {
                      return false;
                  }
              }
          }
  
          return true;
      }
  </code></pre>
  
  <p>I'm curious if this would be possible to execute in a LINQ query?</p>
  
  <p>Thanks in advance for any help!</p>