Last active
October 3, 2019 09:12
-
-
Save AxelUser/da64e43aedfb0f1730f5592d5a7796fe to your computer and use it in GitHub Desktop.
One more reason to read specification
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
using System; | |
namespace RTFM | |
{ | |
class Program | |
{ | |
private struct Mutable | |
{ | |
private int x; | |
public int Mutate() | |
{ | |
x++; | |
return x; | |
} | |
} | |
readonly Mutable m = new Mutable(); | |
public Program() | |
{ | |
Console.WriteLine("-= Mutating from constructor =-"); | |
Console.WriteLine(m.Mutate()); | |
Console.WriteLine(m.Mutate()); | |
Console.WriteLine(m.Mutate()); | |
} | |
static void Main(string[] args) | |
{ | |
Program t = new Program(); | |
Console.WriteLine("-= Mutating from Main =-"); | |
Console.WriteLine(t.m.Mutate()); | |
Console.WriteLine(t.m.Mutate()); | |
Console.WriteLine(t.m.Mutate()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment