| Framework: .NET Framework 4.5.2 | OS: Windows 10 | IDE: Visual Studio |
I have 4 lines of code in the middle of a C# function.
Hashtable A = new Hashtable();
Hashtable B = new Hashtable();
int C = 0;
string D = "";
On launching the code in a debugger in Visual Studio, I get an unusual error on the forth line:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
What is even more stranger is that if I were to remove the line where string D is declared/initialized, the error now shifts to the line above for variable C. The error keeps on shifting to the line before If I now were to remove the lines for variable C then B and eventually A.
What I have already tried.
- I tried to replace the string declaration with String.Empty, it still gave the error.
- Tried declaring and initializing the variable in separate lines, still got the error.
What I need help on?
- Are there any hard limits on the number of variables you can declare in a C# function ?
- How to go by solving this issue ! (Of Course)
Edits
I am limited to sharing the screenshot of the part of the code, not the whole function.