title: How to do this in c#?
body: <p>I have a List of MyClass and in the main page I have 10 controls which will display the information about that list of Items. What I want is to check the count of the items in the List and then make the excess controls invisible. Now I'm using this code but is there an easier way of doing this?</p>
  
  <pre><code> if (myList.Count &gt; 0)
   {
        Control1.MyClassInfo = myList[0];
        if (myList.Count &gt; 1)
        {
             Control2.MyClassInfo = myList[1];
             if (myList.Count &gt; 2)
             {
                  // and like that till 10
             }
             else
             {
                  Control3.Visible = false;
                  Control4.Visible = false;
                  // till 10
             }
         }
         else
         {
             Control2.Visible = false;
             Control3.Visible = false;
             // till 10
         }
    }
    else
    {
         Control1.Visible = false;
         Control2.Visible = false;
         Control3.Visible = false;
         // and then till 10
    }
  </code></pre>