Skip to content

Instantly share code, notes, and snippets.

@jdoig
Created February 21, 2012 21:54
Show Gist options
  • Save jdoig/1879249 to your computer and use it in GitHub Desktop.
Save jdoig/1879249 to your computer and use it in GitHub Desktop.
some .NET 4.0 syntax sugar for immuable state
class Program
{
static void Main(string[] args)
{
var james = new Person(
name: "James",
age: 31,
deceased: false);
}
}
public class Person
{
public readonly string Name;
public readonly ushort Age;
public readonly bool Deceased;
public Person(string name, ushort age, bool deceased)
{
Name = name;
Age = age;
Deceased = deceased;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment