我尝试使用字典,但是我使用了其他类型。
如果使用对象类型,则必须完成转换。
哪种方法是最好的方法?
当前
public class BaseMyClass
{
public bool A;
public string Name;
public double Length;
public double Angle;
public double X1;
public double Y1;
public double X2;
public double Y2;
public double SumA;
public double SumB;
public void Method1()
{
/* do Some */
}
public void Method2()
{
/* do Some */
}
public void Method3()
{
/* do Some */
}
}
我想用这种方式。
public class BaseMyClass
{
public bool A;
public string Name;
public void Method1() {
/* do Some */
}
public void Method2() {
/* do Some */
}
public void Method3() {
/* do Some */
}
}
public class MyA : BaseMyClass
{
public double Length;
public double Angle;
public MyA()
{
Name = "MyA";
}
}
public class MyB : BaseMyClass
{
public double X1;
public double Y1;
public double X2;
public double Y2;
/* more */
public MyB()
{
Name = "MyB";
}
}
public class MyC : BaseMyClass {
public double X1;
public double Y1;
public double SumA;
public double SumB;
public double Length;
public MyC()
{
Name = "MyC";
}
}
/* There are over 100 inherited classes. */
public class Processing
{
public Processing()
{
List<BaseMyClass> list = new List<BaseMyClass>();
/* Get file... or Socket ... Datas in List Random */
// I can see the Name of the class.
// However, members of the class are unknown.
// What should I do ?
}
}