title: C# Reflection Type.GetField array
body: <p>Im trying to read variable array from string and show it in console but each time I run the program Im getting error: &quot;Object reference not set to an instance of an object.&quot; Can anyone suggest how to do this?</p>
  <p>my code:</p>
  <pre><code>public class Positions
  {
     public static string[] test = { &quot;test&quot;, &quot;test2&quot; };
  }
  
  private void test()
  {
     Positions pos = new Positions();
  
     Type type = typeof(Positions);
     FieldInfo fi = type.GetField(&quot;test[0]&quot;);
  
     Console.WriteLine(fi.GetValue(pos));
  }
  </code></pre>