Skip to content

Instantly share code, notes, and snippets.

@AxelUser
Last active October 3, 2019 09:12
Show Gist options
  • Save AxelUser/da64e43aedfb0f1730f5592d5a7796fe to your computer and use it in GitHub Desktop.
Save AxelUser/da64e43aedfb0f1730f5592d5a7796fe to your computer and use it in GitHub Desktop.
One more reason to read specification
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