Created
February 21, 2012 21:54
-
-
Save jdoig/1879249 to your computer and use it in GitHub Desktop.
some .NET 4.0 syntax sugar for immuable state
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
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