Skip to content

Instantly share code, notes, and snippets.

@ploeh
Forked from yreynhout/KeepImmutableSanity_Classic.cs
Last active December 17, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ploeh/5599253 to your computer and use it in GitHub Desktop.
Save ploeh/5599253 to your computer and use it in GitHub Desktop.
public class ImmutableXYZ {
public ImmutableXYZ() : this("", 0, -1) {
}
private ImmutableXYZ(string abc, int def, int haha)
{
this.abc = abc;
this.def = def;
this.haha = haha;
}
public ImmutableXYZ WithABC(string value) {
return new ImmutableXYZ(value, this.def, this.haha);
}
public ImmutableXYZ WithDEF(int value) {
return new ImmutableXYZ(this.abc, value, this.haha);
}
public ImmutableXYZ WithHaha(int value) {
return new ImmutableXYZ(this.abc, this.def, value);
}
public readonly string ABC;
public readonly int DEF;
private readonly int haha;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment