I have some code that uses a class that was converted from Java with IKVM for use in .NET. So my code sample uses VAR when instantiating the class, such as:
var Something = new OriginallyFromJavaClass("c:\ReadInThisFile.txt");
Then methods of this class do something with that text file like:
var analyze = OriginallyFromJavaClass.method1(whatever);
Notice that these other uses of the class do NOT reference "Something" but just call the java class name directly without the "new" word.
The problem is that reading the text file once takes like 30 seconds so I want to do it just once in my WinForms application and then call the other methods within a button click. But if I move the above line of code up to my class level so I only have to open the TXT file once, the C# compiler fails because it doesn't allow VAR types at a class level. I know fundamentally and from using GetType to evaluate this variable that it is a class. So how would I restructure the above using explicit types and where I instantiate the class (thus reading my TXT file) just once?