How to create an array of tuples?
c#
Solution
You can define it as follows:
Tuple<int, int>[] tuples =
{
Tuple.Create(50, 350),
Tuple.Create(50, 650),
...
};
Though if this is coordinate values, I'd probably use Point instead:
Point[] points =
{
new Point(50, 350),
new Point(50, 650),
...
};
Problem
I know that to create a tuple in C#, we use the format: ``` Tuple <int,int>from = new Tuple<int,int>(50,350); Tuple <int,int>to = new Tuple<int,int>(50,650); ``` where each tuple is a coordinate pair. I am trying to create an array of multiple coordinate pairs using tuples. Could someone help me out on this? EDIT: This is what I have tried so far. I want it to be in this array format only. ``` Tuple<int, int>[] coords = new Tuple<int,int>({50,350},{50,650},{450,650}); ``` Compiler complains that there is something wrong.. Please tell me what it is?