Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class RefReturns
{
public RefReturns()
{
this._grade = 2;
}
private int _grade;
public void PrintGrade()
{
Console.WriteLine($"Grade: {this._grade}");
}
public ref int DoStuff()
{
return ref this._grade;
}
}
class Program
{
static void Main(string[] args)
{
RefReturns refReturns = new RefReturns();
ref int grade = ref refReturns.DoStuff();
grade = 17;
refReturns.PrintGrade();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment