In my C# code I have a list of Tuples. The tuples themselves consist of two numbers of the type double
and an object of type LocalDate
.
List<Tuple<double, double, LocalDate>> tupleList = new List<Tuple<double, double, LocalDate>>();
The list, for instance, could look as follows.
1, 10, LocalDate1
12, 310, LocalDate2
31, 110, LocalDate3
What is an elegant way to create an array of doubles that only contains the first double values of each list item?
Accordingly, I want an ArrayList that only consists of the LocalDate
objects in the list. The order should be preserved.
The expected result should be:
double[] => [1, 12, 31]
double[] => [10, 310, 110]
ArrayList<> => [LocalDate1, LocalDate2, LocalDate3]
I am aware that the ordinary way would be to iterate over the list in a for loop and create the arrays via this loop. However, I think that there should be a more concise and elegant way.