我有一个 A 类,它有 2 个普通属性(字符串属性)和 1 个静态属性(A 类型列表)。在构造函数中创建 A 类的新实例时,我想将该实例添加到静态列表属性中。我有两个问题。
1-有可能吗?
2-如果可能的话,我该如何实施。
我正在使用以下代码:
public class A {
private string _property1;
private string _property2;
private static List<A> _AList;
public string Property1 {
get { return _property1; }
set { _property1 = value; }
}
public string Property2 {
get { return _property2; }
set { _property2 = value; }
}
public static List<A> AList {
get { return _AList; }
set { _AList = value; }
}
public A( ) {
}
}