abstract class foo
{
public string myId {get;set;}
public string mystring {get;set;}
public foo3 my3rdFoo {get;set}
}
class foo2 : foo
{
public string myFavoriteFoo {get;set;}
}
class foo3:foo2
{
public string myName{get;set}
}
を使用してインスタンス化
Foo3 myThirdFoo = new foo3();
string result = foo3.myName;
foo2 内から 3 番目の foo にアクセスする場合は、このコードを使用します。
abstract class foo
{
public string myId {get;set;}
public string mystring {get;set;}
public foo3 my3rdFoo {get;set}
}
class foo2 : foo
{
public foo3 myFavoriteFoo {get;set;}
}
class foo3
{
public string myName{get;set}
}
そして、次のように使用します
foo3 ThirdFoo = new foo3();
ThirdFoo.myName = "Something nice";
foo2 SecondFoo = new foo2(){myFavouriteFoo = ThirdFoo};
String Result = SecondFoo.myFavouriteFoo.myName;
さらに別の方法は
abstract class foo
{
public string myId {get;set;}
public string mystring {get;set;}
public foo3 my3rdFoo {get;set}
}
class foo2 : foo
{
public foo3 myFavoriteFoo {get;set;}
public foo2(string myName)
{
foo3 = new foo3();
foo3.myName = myName;
}
}
class foo3
{
public string myName{get;set}
}
そして、それを使用してアクセスします
foo2 SecondFoo = new foo2("Something nice");
String Result = SecondFoo.myfavouritefoo.myName;