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.
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();
}
}
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.