Why is the easy tuple declaration syntax (int, double) t1 = (17, 3.14); not available for 1-tuple ?
CS8124 : Tuple must contain at least two elements seems odd when ValueTuple exists, isnt it ?
public class MyDict : Dictionary<(int a, int b), int> // ok
{
public MyDict()
{
Add(new ValueTuple<int, int>(1, 2), 0);
}
}
public class MyDict2 : Dictionary<(int a), int> // Error CS8124 : Tuple must contain at least two elements.
{
}
public class MyDict3 : Dictionary<ValueTuple<int, int>, int> // ok
{
public MyDict3()
{
Add((1, 2), 0);
}
}
public class MyDict4 : Dictionary<ValueTuple<int>, int> // ok
{
public MyDict4()
{
Add((1), 0); // Argument of type int is not assignable to parameter type System.ValueTuple<int>
Add(ValueTuple.Create(1), 0); // ok
}
}