C#.NETでプログラミングしています。それを作成したインスタンスのメンバーにアクセスできるネストされたクラスを作成したいのですが、方法がわかりません。
これは私がやりたいことです:
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.
どうすればいいのですか?Car クラス内に Door クラスをネストしようとしましたが、そのように Car クラスのメンバーにアクセスできません。Car にドアクラスなどを継承させる必要がありますか?