title: Access into global variable by Console.Readline() in C#
body: <p>I'm trying to improve my program for Fibonacci numbers using of memoization:</p>
  
  <pre><code>public class MyGlobals
  {
      public long TotNum { get; set; }
      public long[] MyNumbers { get; set; }
  
      public void GetParam() 
      {
          Console.Write("n = ");
          this.TotNum = long.Parse(Console.ReadLine());
          this.MyNumbers = new long[this.TotNum + 1];
          // set all numbers to -1
          for (int i = 0; i &lt; this.MyNumbers.Length; i++)
          {
              this.MyNumbers[i] = -1;
          }
      }
  }
  
  class Program
      {
          static void Main(string[] args)
          {
              MyGlobals globVariable = new MyGlobals();
  
              globVariable.GetParam();
              long n = globVariable.TotNum;
  
              Console.WriteLine("Fib ({0}) = {1}", n, Fibonacci(n));
  
              Console.ReadKey();
          }
  
          static long Fibonacci(long n)
          {
              MyGlobals globVariable = new MyGlobals();
  
              if (n &lt;= 1)
              {
                  return 1;
              }
              if (globVariable.MyNumbers[n] != -1)
              {
                  return globVariable.MyNumbers[n];
              }
              else
              {
                  globVariable.MyNumbers[n] = Fibonacci(n - 1) + Fibonacci(n - 2);
              }
              return globVariable.MyNumbers[n];
          }
     }
  </code></pre>
  
  <p>I'm trying to do something like feed an array by -1 in MyGlobals class for further using MyNumbers array in Fibonacci static method.
  Until line where I'm starting to call recursive fibonacci method it holds MyNumbers array in memory. But in Fibonacci method, when I create new instance of MyGlobals class for calling MyNumbers array is this array empty... What I'm doing wrong. Can you anybody help me on this, please. Thank you very much in forward.</p>