title: Acces method of a class, in iteration of foreach
body: <p>I'm trying to acces to a method of a class, stored in an arraylist on a foreach, but it doesn't work.
  For example:</p>
  <p>Having the following class:</p>
  <pre><code>class MyClass
  {
      private int number;
      public MyClass()
      {
         this.number = 0;
      }
      public void addNumber(int add) 
      {
           this.number += add;
      }
  }
  </code></pre>
  <p>If then in my main class i do this:</p>
  <pre><code>MyClass myclass = new MyClass();
  ArrayList myarray = new ArrayList();
  myarray.Add(myclass);
  foreach ( MyClass mclss in myarray )
  {
       mclss.addNumber(2);
  }
  </code></pre>
  <p>It says &quot;mclss does not contains any definition for addNumber...&quot;
  How can i do this?</p>
  <p>Thanks for the help!</p>