I have a custom class named Component. Said class gets populated with 4 attributes. I then try to add this class to a List and in this step of the process I get the Object reference not set error. In debugging it I have pines the issue in the add function. Note that I do understand the error just cant pin what is wrong in this specific situation I don't think it is a duplicated question but I do accept link to any question that solves this situation.
List<Components.Component> partList = new List<Components.Component>();
firstUsages = false;
Components.Component targetComponent = new Components.Component();
targetComponent.A = 5;
targetComponent.B = 8;
targetComponent.C = 10;
targetComponent.TypeComponent = "Teste";
partList.Add(targetComponent);
Custom Class:
class Component
{
double a, b, c;
string typeComponent;
public double A { get => a; set => a = value; }
public double B { get => b; set => b = value; }
public double C { get => c; set => c = value; }
public string TypeComponent { get => typeComponent; set => typeComponent = value; }
}