Skip to content

Instantly share code, notes, and snippets.

@codewithcats
Created September 5, 2012 01:55
Show Gist options
  • Save codewithcats/3629077 to your computer and use it in GitHub Desktop.
Save codewithcats/3629077 to your computer and use it in GitHub Desktop.
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