Created
February 1, 2015 07:05
-
-
Save ufcpp/fe9b2e5d9bbcd2e1c7e7 to your computer and use it in GitHub Desktop.
readonly struct field
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
struct Point | |
{ | |
public int X { get; set; } | |
public int Y { get; set; } | |
} | |
class B | |
{ | |
public readonly Point P = new Point(); | |
} | |
class Program | |
{ | |
static void Main() | |
{ | |
var b = new B(); | |
b.P.X = 10; // ちゃんとエラー。P が構造体の時には有効。 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment