Created
December 30, 2017 09:33
-
-
Save Ibro/08a009c7f62f7210411203425708be1e to your computer and use it in GitHub Desktop.
C# 7 - Return reference - https://codingblast.com/csharp-7-return-reference-local-reference/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RefLocals | |
{ | |
private int _age = 15; | |
public void ReferenceToField() | |
{ | |
ref int someReferenceToAge = ref _age; | |
someReferenceToAge = 45; | |
} | |
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