I'm currently working on a .NET core 2.1 project using C# 7+. I want to use a Named Tuple as the result of my method. Somehow I cannot manage to correctly create the method return parameters.
So far I have:
public static Tuple<List<Dictionary<string, object>>, List<KeyValuePair<int, Dictionary<string, float>>>> CreateFruits()
{
// logic to create apples and oranges
return new Tuple<List<Dictionary<string, object>>, List<KeyValuePair<int, Dictionary<string, float>>>>(apples, oranges);
}
When I use my method Create Fruits I currently can use Apples and Oranges like that:
var result = MyHelper.CreateFruits();
var apples = result.Item1;
var oranges = result.Item2;
Instead of Item1 and Item2 I would like to use something like Apple and Orange.
var result = MyHelper.CreateFruits();
var apples = result.Apple;
var oranges = result.Orange;
Is it actually possible, I've read something about Named Tuples in C# 7, but I'm not so sure about how to use them correctly, especially with complex datatypes.
Do you know how to solve this issue?
Thanks a lot!