There are a couple of problems here: first off C# doesn;t have global variables: everything is within a class. The closest you can get is to have a static variable inside a class and that will be available to the whole code via the class name:
public class MyClass
{
public static int globalValue = 666;
...
}
...
public class MyOtherclass
{
private void MyMethod()
{
Console.WriteLine(MyClass.globalValue);
}
}
When you do that, you can use a static constructor for MyClass to initialize the variable:
public class MyClass
{
public static string globalValue;
static MyClass()
{
globalValue = File.ReadAllText(@"D:\Test Data\Primes.txt");
}
}
The static constructor will be called before the variable is used.