C# プロジェクトで Visual Studio 2012 Express を使用しています。Visual Studio の以前のバージョンではそうではなかったことを覚えているようで、これがバグであるかどうか疑問に思っています。
以下のコードでは、Empty は静的な読み取り専用フィールドですが、Empty.Clear() を使用してコンストラクターの外で変更できます。
public struct Box
{
public static readonly float D = float.MaxValue;
public static readonly Box Empty = new Box(new Vector3(D, D, D), new Vector3(-D, -D, -D));
public Vector3 Min;
public Vector3 Max;
public Box(Vector3 min, Vector3 max)
{
Min = min;
Max = max;
}
public void Clear()
{
Min = new Vector3(D, D, D);
Max = -Min;
Empty.Clear(); // I seem to remember this should not be allowed
}
}