Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ref returns, ref locals, ref readonly, and ref struct with C# 7
// ref returns and ref locals with C# 7.0
int[] _numbers = { 3, 7, 11, 15, 21 };
public ref int GetNumber(int index)
{
return ref _numbers[index];
}
// ref readonly with C# 7.2
int[] _numbers = { 3, 7, 11, 15, 21 };
public ref readonly int GetNumber(int index)
{
return ref _numbers[index];
}
// ref struct with C# 7.2
ref struct OnlyOnTheStack
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment