我想将 linq 结果分配给双数组。我有两个对象数组。我像下面这样获取它们:
var chartSeries = MeterReadings.GroupBy(x => x.Name)
.Select(g => new
{
Name = g.Key,
Data = g.Select(x => x.Value).ToArray(),
Date = g.Select(x => x.ReadDate).ToArray()
}).ToArray();
并尝试分配代码:
foreach (var item in chartSeries)
{
int length = item.Data.Length;
object[,] data = ??? //first array item.Data and second item.Dates
Series localSeries = new Series
{
Name = item.Name, Data = new Data(data), Type = ChartType
};
Series.Add(localSeries);
}
这一行object[,] data = ???
我应该写什么?我想要类似的东西object[,] data = { item.Data, item.Dates }
我试图得到这样的:
Data = new Data(new object[,]
{
{ new DateTime(1970, 9, 27), 0 },
{ new DateTime(1970, 10, 10), 0.6 },
{ new DateTime(1970, 10, 18), 0.7 },
{ new DateTime(1970, 11, 2), 0.8 },
{ new DateTime(1970, 11, 9), 0.6 },
{ new DateTime(1970, 11, 16), 0.6 },
{ new DateTime(1970, 11, 28), 0.67 },
{ new DateTime(1971, 1, 1), 0.81 },
{ new DateTime(1971, 1, 8), 0.78 },
{ new DateTime(1971, 1, 12), 0.98 },
{ new DateTime(1971, 1, 27), 1.84 },
{ new DateTime(1971, 2, 10), 1.80 },
{ new DateTime(1971, 2, 18), 1.80 },
{ new DateTime(1971, 6, 12), 0 }
})
谢谢...