Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created December 30, 2017 12:13
Show Gist options
  • Save Ibro/a88d192eb7fef07557c2540ea2ecfc99 to your computer and use it in GitHub Desktop.
Save Ibro/a88d192eb7fef07557c2540ea2ecfc99 to your computer and use it in GitHub Desktop.
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