title: What can be done to shorten my if-else code?
body: <p>Is there a way to shorten this C# code?</p>
  
  <pre><code>    byte[] temp = new byte[3];
      InventoryKeyItemID = LoadData_readbytes(offset + 0x5ED, 3, file);
      temp[0] = InventoryKeyItemID[0];
      if (temp[0] &gt;= 128)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(7, true);
          temp[0] -= 128;
      }
      if (temp[0] &gt;= 64)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(6, true);
          temp[0] -= 64;
      }
      if (temp[0] &gt;= 32)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(5, true);
          temp[0] -= 32;
      }
      if (temp[0] &gt;= 16)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(4, true);
          temp[0] -= 16;
      }
      if (temp[0] &gt;= 8)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(3, true);
          temp[0] -= 8;
      }
      if (temp[0] &gt;= 4)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(2, true);
          temp[0] -= 4;
      }
      if (temp[0] &gt;= 2)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(1, true);
          temp[0] -= 2;
      }
      if (temp[0] &gt;= 1)
      {
          checkedListBox_Inventory_KeyItems.SetItemChecked(0, true);
      }
  </code></pre>
  
  <p>What this code does,</p>
  
  <ol>
  <li>Three bytes of data is read from a file then stored to InventoryKeyItemID array.</li>
  <li>The value of InventoryKeyItemID[0] is stored to temp[0].</li>
  <li>Checking the temp[0] variable using if-else statements to select what checkedListBox item would be checked.</li>
  </ol>