Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created February 1, 2015 07:05
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 ufcpp/fe9b2e5d9bbcd2e1c7e7 to your computer and use it in GitHub Desktop.
Save ufcpp/fe9b2e5d9bbcd2e1c7e7 to your computer and use it in GitHub Desktop.
readonly struct field
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