次のプロパティは、getter と setter の両方に対して 1 回計算される値を要求するだけです。
したがって、代わりに:
public bool this[int x, int y]
{
get
{
return this[x * this.width + y];
}
set
{
this[x * this.width + y] = value;
}
}
これができればもっと良いです:
public bool this[int x, int y]
{
int index = x * this.width + y;
get
{
return this[index];
}
set
{
this[index] = value;
}
}
この場合、それほど大したことではなく、インライン メソッドを使用できます。しかし、原則として、方法はありますか?