Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class RefLocals
{
private int _age = 15;
private int[] _numbers = { 3, 2, 5, 4 };
public void ReferenceToField()
{
ref int someReferenceToAge = ref _age;
someReferenceToAge = 45;
ref int secondElement = ref _numbers[1];
secondElement = 33;
}
public void PrintAge()
{
Console.WriteLine($"Age: {_age}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment