Im programming in C#.NET. I want to create a nested class that can access members of the instance that created it but I can't seem to figure out how.
This is what I want to do:
Car x = new Car()
x.color = "red";
x.Door frontDoor = new x.Door();
MessageBox.Show(frontDoor.GetColor()); // So I want the method GetColor of the class Front Door to be able to access the color field/property of the Car instance that created it.
How do I do it? I tried nesting the Door class inside the Car class but it can't access the members of the Car class that way. Do I need to make Car inherit the door class or something?