开发者

Convert List to Double Array by LINQ (C#3.0)

I have two lists x1 and x2 of type double

List<double> x1 = new List<double> { 0.0330, -0.6463};
List<double> x2 = new List<double> { -0.2718, 开发者_如何学Go-0.2240};

I am using the below function to convert it to double array

List<List<double>> xData = new List<List<double>> { x1, x2 };
            double[,] xArray = new double[xData.Count, xData[0].Count];

            for (int i = 0; i < xData.Count; i++)
            {
                for (int j = 0; j < xData[0].Count; j++)
                {
                    xArray[i, j] = xData[i][j];
                }
            }

Is it possible to do the same stuff (i.e. the function that is converting List to array) by using Linq.

Using : (C#3.0) & Framework - 3.5

I want to do this by using Linq because I am learning it but not have sufficient knowledge to write that.

Thanks

Convert List to Double Array by LINQ (C#3.0)


There may be some way of doing it, but I don't believe LINQ has any built-in support for rectangular arrays.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜