Last active
September 26, 2015 05:48
-
-
Save monoman/1048921 to your computer and use it in GitHub Desktop.
I would do differently on a light C# example from http://www.trelford.com/blog/post/LighterCSharp.aspx
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
public class Person { | |
public Person(string name, int age) { | |
_name = name; | |
_age = age; | |
} | |
private readonly string _name; | |
private readonly int _age; | |
/// Full name | |
public string Name { get _name; } | |
/// Age in years | |
public int Age { get _age; } | |
} | |
/// In C# 6.0 you can do | |
public class Person { | |
public Person(string name, int age) { | |
Name = name; | |
Age = age; | |
} | |
/// Full name | |
public string Name { get; } // private setter implied on this auto-property | |
/// Age in years | |
public int Age { get; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment