Created
November 30, 2016 22:46
-
-
Save controlflow/195fe5347e392b9b4bde7227aca7d5d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 OldSchoolPerson { | |
public string Name { get; set; } | |
public int Age { get; set; } | |
} | |
public class ModernPerson { | |
private string _name; | |
private int _age; | |
public ref string Name => ref _name; | |
public ref int Age => ref _age; | |
} | |
public class C { | |
public void M() { | |
var oldSchool = new OldSchoolPerson { Name = "Alex", Age = 27 }; | |
var modern = new ModernPerson { Name = "Alex", Age = 13 }; | |
ModernStringMutator(ref oldSchool.Name); | |
ModernStringMutator(ref modern.Name); | |
} | |
public void ModernStringMutator(ref string text) { | |
text += "abc"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment