Compiler Error CS8132
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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for