I have a static class that looks like this:
namespace Argus
{
static class Argus
{
public static List<Branch> myArgus;
}
}
and elsewhere in my code I have this:
// Add this branch to myArgus
Argus.myArgus.Add(branch);
When I run the code, I get this error:
Object reference not set to an instance of an object.
I have verified that branch is valid (it’s an object of the Branch class), and have no idea what could be wrong here. I’m trying to read branch data in from a text file.
You need to instantiate it; it’s default value is null otherwise: