简体   繁体   English

C#数组到数组数组的列表

[英]C# List of arrays to array of arrays

I am new to C#. 我是C#的新手。 I am writing a program in which a list changes size depending on user input. 我正在编写一个程序,其中列表根据用户输入改变大小。 The list is of GPS coordinates so it is 列表是GPS坐标,所以它是

List<double[]> coordinates= new List<double[]>();

However I have a function that needs the GPS coordinates in double[][] format, an array of arrays. 但是我有一个需要double[][]格式的GPS坐标的函数,一个数组数组。 It seems like this would be very straightforward because it seems like a list of arrays is already an array of arrays. 看起来这很简单,因为它似乎是一个数组列表已经是一个数组数组。 However, the most logical thing I can think to do fails: 但是,我认为最合乎逻辑的事情就是失败:

double[][]test = new double[][]{};

test = coordinates.ToArray;

with "Cannot convert method group 'ToArray' to non-delegate type 'double[][]'. Did you intend to invoke the method?" 使用“无法将方法组'ToArray'转换为非委托类型'double [] []'。您是否打算调用该方法?”

Not sure what that means or how to fix. 不确定这意味着什么或如何解决。 Any advice is appreciated. 任何建议表示赞赏。

要在C#中调用方法,需要使用括号,如下所示: test = coordinates.ToArray();

你忘了括号:

double[][]test = coordinates.ToArray();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM