title: Compare properties of two objects fast c#
body: <p>I have two objects of same type with different values:</p>
  
  <pre><code>    public class Itemi
      {
      public Itemi()
      {
  
      }
  
      public int Prop1Min { get; set; }
      public int Prop1Max { get; set; }
  
      public int Prop2Min { get; set; }
      public int Prop2Max { get; set; }
  
      public int Prop3Min { get; set; }
      public int Prop3Max { get; set; }
      ...................................
      public int Prop25Min { get; set; }
      public int Prop25Max { get; set; }
  
      }
  </code></pre>
  
  <p>Now I instantiate two objects of this type and add some values to their properties.</p>
  
  <pre><code>Itemi myItem1 = new Itemi();
  
  myItem1.Prop1Min = 1;
  myItem1.Prop1Max = 4;
  
  myItem1.Prop2Min = 2;
  myItem1.Prop2Max = 4;
  
  myItem1.Prop3Min = -1;
  myItem1.Prop3Max = 5;
  
  .............................
  
  myItem1.Prop25Min = 1;
  myItem1.Prop25Max = 5;
  
  Itemi myItem2 = new Itemi();
  
  myItem2.Prop1Min = 1;
  myItem2.Prop1Max = 5;
  
  myItem2.Prop2Min = -10;
  myItem2.Prop2Max = 3;
  
  myItem2.Prop3Min = 0;
  myItem2.Prop3Max = 2;
  
  ................................
  
  myItem2.Prop25Min = 3;
  myItem2.Prop25Max = 6;
  </code></pre>
  
  <p>What is the best and fastest way to do this comparison:</p>
  
  <ul>
  <li>take each properties from myItem1 and check if values from Prop1-25 Min and Max are within the range values of myItem2 Prop1-25 Min and Max </li>
  </ul>
  
  <p>Example:  </p>
  
  <pre><code>   myItem1.Prop1Min = 1
     myItem1.Prop1Max = 4
  
     myItem2.Prop1Min = 1
     myItem2.Prop1Max = 5
  </code></pre>
  
  <p>this is True because mtItem1 Prop1 min and max are within the range of myItem2 min and max.</p>
  
  <p>the condition should be AND in between all properties so in the end after we check all 25 properties if all of them are within the range of the second object we return true.</p>
  
  <p>Is there a fast way to do this using Linq or other algorithm except the traditional if-else?</p>