ValueTuple as a new feature in C# 7.0 is having public method Create
which helps to create ValueTuples (from singleton to octuple
or more) on the other hand we can also use new
to achieve the same results. I noticed these behave differently. I am trying to research is below implementation wrong or this is something as per design:
Method CreateOctuple()
is working as expected:
private static ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>> CreateOctuple()
{
return new ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>(1, 2, 3, 4, 5, 6, 7, new ValueTuple<int>(8)); ;
}
Now, I tried to achieve same output using Create()
method, unfortunately, it is complaining about the return type:
private static ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>> OctupleUsingCreate()
{
return ValueTuple.Create(1, 2, 3, 4, 5, 6, 7, ValueTuple.Create(8));
}
P.S. All packages are up-to-date and I am using Visual Studio 2017 -latest release.
As suggested by Svick
static ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>> OctupleUsingCreate()
{
return ValueTuple.Create(1, 2, 3, 4, 5, 6, 7, 8);
}