Considering two classes in C #:
public class aClass
{
public string afield;
}
public class bClass
{
public aClass[] bfield;
}
I want to start the variable as
bClass cVar = new bClass();
cVar.bfield[0].afield = "text";
but is generating the following error during the debug.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
cVar.bfield was null.
How do I start the variable to avoid this error?