Created
May 14, 2012 04:02
-
-
Save marcioalthmann/2691720 to your computer and use it in GitHub Desktop.
keyword readonly
This file contains 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 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