Compiler Error CS8130
Cannot infer the type of implicitly-typed deconstruction variable.
Example
The following sample generates CS8130:
// CS8130.cs (5,14)
class Program
{
static void Main()
{
var (x2, y2) = () => { };
}
}
The compiler cannot convert a delegate (Action
) to a two-element tuple and thus is unable to infer the type of each element of the tuple.
To correct this error
To assign a value to a tuple, ensuring the right-hand-side expression is a tuple with the same number of elements as that on the left-hand-side corrects this error:
static void Main()
{
var (x2, y2) = (1, 2);
}
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