我有以下类作为列表;
class list_TA
{
public DateTime SAMPLE_TIME { get; set; }
public string WAIT_CLASS { get; set; }
public double COUNT { get; set; }
public list_TA(DateTime SAMPLE_TIME, string WAIT_CLASS,double COUNT)
{
this.SAMPLE_TIME = SAMPLE_TIME;
this.WAIT_CLASS = WAIT_CLASS;
this.COUNT = COUNT;
}
}
//SECOND PART
var test = listASH
.Select(g => new
{
SAMPLE_TIME = statiClass.By15Seconds(Convert.ToDateTime(g.SAMPLE_TIME)),
WAIT_CLASS = g.WAIT_CLASS,
COUNT = 0,
}).GroupBy(x => new { x.SAMPLE_TIME, x.WAIT_CLASS })
.Select(y => new
{
SAMPLE_TIME = y.Key.SAMPLE_TIME,
WAIT_CLASS = y.Key.WAIT_CLASS,
COUNT = Math.Round(y.Count() / 15.0, 2),
});
我想要的是将linq结果加载到list_TA中。但是下面的代码不起作用,它给出了以下错误;
List<list_TA> lst = (List<list_TA>)test.ToList();
错误;
Cannot convert type 'System.Collections.Generic.List<<anonymous type: System.DateTime SAMPLE_TIME, string WAIT_CLASS, double COUNT>>' to 'System.Collections.Generic.List<vodaMon.list_TA>'
正在转换为列表();不起作用。
Helenr
慕仙森
慕斯709654
相关分类