title: Calling the methods of an object instantiated in one method, from another method
body: <p>I'm trying to call a method of an object that was instantiated in one method (<code>ObjectInstantiation()</code>), from another method (<code>Main()</code>). I boil down to this:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ConsoleApplication1
  {
      class Program
      {
          public static void ObjectInstantiation()
          {
              TestClass testClass1 = new TestClass(6);
              TestClass testClass2 = new TestClass(7);
          }
  
          static void Main()
          {
              ObjectInstantiation();
              testClass1.PrintNumber();
              Console.ReadLine();
          }
      }
  
      class TestClass
      {
          int number;
  
          public TestClass(int i)
          {
              number = i;
          }
  
          public void PrintNumber()
          {
              Console.WriteLine(number);
          }
      }
  }
  </code></pre>
  
  <p>This throws the error "The name 'testClass1' does not exist in the current context"
  I understand that I could just instantiate them from within <code>Main()</code>, but I also need to access the object's methods from within a third method, separate from <code>ObjectInstantiation()</code> and <code>Main()</code>, so I run into the same issue again.</p>
  
  <p>I should add that it's important that there are multiple instances of the class, as each one will store different values.</p>