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

C++
SampleClass sample;
Console.Write($"{sample.x}");
// instead do this:
SampleClass sample = new SampleClass();
Console.Write($"{sample.x}");long[][] array = new long[1][];
array[0][0] = 3; // is null because only the first dimension is yet initialized.
                 // Use array[0] = new long[2]; first.Dictionary<string, int> agesForNames = null;
int age = agesForNames["Bob"]; // agesForNames is null.
                               // There is no Dictionary to perform the lookup.
Source

Also in C++: