Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Cannot deconstruct a tuple of elements into variables.
Example
The following sample generates CS8132:
// CS8132.cs (5,9)
class Program
{
static void F(object x, object y, object? z)
{
(object? a, object? b) = (x, y, z = 3);
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(z);
}
}
To correct this error
To deconstruct to a tuple with a smaller number of elements, using the discard variables will correct this error:
class Program
{
static void F(object x, object y, object? z)
{
(object? a, object? b, object _) = (x, y, z = 3);
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(z);
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.