【发布时间】:2017-11-01 20:32:35
【问题描述】:
我有如下所示的通用列表 foo
var foo = new List<XYZ>();
public class XYZ
{
public String TimeZone { get; set; }
public Decimal? B1Volume { get; set; }
public Decimal? B2Volume { get; set; }
public Decimal? B3Volume { get; set; }
public Decimal? B4Volume { get; set; }
public Decimal? B5Volume { get; set; }
// .............
// .............
public Decimal? B24Volume { get; set; }
public String Name {get;set;}
}
如何选择属性B1Volume,........B24Volume ?
我尝试使用下面提到的以下代码,但它没有给出预期的结果
var hp = foo.Skip(1).Take(23).ToList();
【问题讨论】:
-
当然没用。
Skip,Take... 适用于对象而不是它们的属性。当您有这样的列表时,它可以工作:{xyz1, xyz2 .... xyz24}
标签: c# linq generic-list