bookmanu
0
Q:

object reference not set to an instance of an object c#

Dictionary<string, int> agesForNames = null;
int age = agesForNames["Bob"]; // agesForNames is null.
                               // There is no Dictionary to perform the lookup.
4
SampleClass sample;
Console.Write($"{sample.x}");
// instead do this:
SampleClass sample = new SampleClass();
Console.Write($"{sample.x}");
1

Tags

New to Communities?

Join the community