C# Error
CS8150 – By-value returns may only be used in methods that return by value
Reason for the Error & Solution
By-value returns may only be used in methods that return by value
Example
The following sample generates CS8150:
// CS8150.cs (6,9)
class C
{
ref int M()
{
return new();
}
}
To correct this error
To return by value, refactor the method from being by reference. For example:
// CS8150.cs (6,9)
class C
{
int M()
{
return new();
}
}