3 つのクラスがある場合、Mainclass、ChildClass、OtherChild とします。
MainClass()
{
ChildClass cc = new ChildClass();
OtherChild oc = new OtherChild();
//Set the name property of childclass
string childName = "some name";
}
ChildClass()
{
public string name {get; set;}
}
OtherChild()
{
//Here i want to get the name property from ChildClass()
//Doing this will make a new instance of ChildClass, which will not have the name property set.
ChildClass cc = new ChildClass();
}
これに対する解決策は何ですか?