Created
September 5, 2012 01:55
-
-
Save codewithcats/3629077 to your computer and use it in GitHub Desktop.
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
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_43 | |
{ | |
class Employee | |
{ | |
public Employee(int id) | |
{ | |
Id = id; | |
} | |
// ... | |
public readonly int Id; | |
public void SetId(int newId) | |
{ | |
// ERROR: read-only fields cannot be set | |
// outside the constructor. | |
// Id = newId; | |
} | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment