Skip to content

Instantly share code, notes, and snippets.

@mgravell
Created August 6, 2020 09:31
Show Gist options
  • Save mgravell/c46a1de553abe325dea0c44ac7fa7766 to your computer and use it in GitHub Desktop.
Save mgravell/c46a1de553abe325dea0c44ac7fa7766 to your computer and use it in GitHub Desktop.
using System;
class Foo
{
int _value;
public ref int Value => ref _value;
static void Main()
{
var obj = new Foo { Value = 12 };
Console.WriteLine(obj.Value);
obj.Value = 42;
Console.WriteLine(obj.Value);
Magic(ref obj.Value);
Console.WriteLine(obj.Value);
}
static void Magic(ref int evil) => evil++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment