Kyle Wright
Kyle Wright

Reputation: 520

C# List of arrays to array of arrays

I am new to 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

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

However I have a function that needs the GPS coordinates in double[][] format, an array of arrays. 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?"

Not sure what that means or how to fix. Any advice is appreciated.

Upvotes: 3

Views: 3497

Answers (2)

Ketchup
Ketchup

Reputation: 3111

You forgot the parenthesis:

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

Upvotes: 4

recursive
recursive

Reputation: 86144

To call a method in C#, you need to use parentheses, like this: test = coordinates.ToArray();

Upvotes: 10

Related Questions