我有2个列表:A类型和Aa类型之一。 AA型是由A型 所以继承:公共属性列表需要Concat 2继承类型
List<A> listA = new List<A>();
List<Aa> listAa = new List<Aa>();
与
class Aa : A
我:
public property Lists<A>
{
get
{
List<A> newList = new List<A>();
//return concat of both lists
foreach(List l in listA)
{
newList.Add(l);
}
foreach(List l in listAa)
{
newList.Add(l);
}
}
我可以以某种方式使用,而不是foreach循环的毗连?即
get
{
return listA.Concat(listAa);
} // this doesn't work
其次,我该如何做属性的设置部分?
set
{
//figure out the type of variable value and put into appropriate list?
}
@Obalix:从原来的,我不是100%肯定这些都是通用的清单,而不是System.Collections.List .. – 2010-03-22 16:26:24
@Reed Copsey:刚做格式化...... :-) ......根据Bernard的OP,列表被定义为列表和列表。 –
AxelEckenberger
2010-03-22 16:33:03
啊,好吧 - 从原始文本中并不明显,它包含:“List listA = new List();”等等,表明非泛型用法。 – 2010-03-22 16:50:53