我有两个班级:
public class a
{
public List<b> b { get; set; }
public c c { get; set; }
}
public class c
{
public int count { get { return ?????????? } }
}
我想在班级Count
a.b
的{{1}}属性
答案 0 :(得分:0)
您可以a
依赖c
并从那里访问b
public class a
{
public a() {
b = new List<b>();
c = new c(this);
}
public List<b> b { get; set; }
public c c { get; set; }
}
public class c
{
private a _a;
public c(a _a) { this._a = _a; }
public int count { get { return _a.b.Count; } }
}