Skip to content

Instantly share code, notes, and snippets.

@marcioalthmann
Created May 14, 2012 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcioalthmann/2691720 to your computer and use it in GitHub Desktop.
Save marcioalthmann/2691720 to your computer and use it in GitHub Desktop.
keyword readonly
class Foo
{
private readonly double _pi = 3.14;
private readonly double _foo;
public Foo()
{
_foo = Double.MaxValue;
}
public void Bar()
{
// não é permitido definir o valor de um field readonly fora da sua declaração
// ou do construtor da classe, esse código da erro de compilação.
_foo = Double.MinValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment