set {
if(ok(index1, index2)) {
a[index1, index2] = value;
ErrFlag = false;
}
else
ErrFlag = true;
}
}
// Возвратить логическое значение true, если
// индексы находятся в установленных пределах,
private bool ok(int index1, int index2) {
if (index1 >= 0 & index1 < rows & index2 >= 0 &
index2 < cols) return true;
return false;
}
}
// Продемонстрировать применение двумерного индексатора,
class TwoDIndexerDemo {
static void Main() {
FailSoftArray2D fs = new FailSoftArray2D(3, 5);
int x;
// Выявить скрытые сбои.
Console.WriteLine("Скрытый сбой.");
for (int i=0; i < 6; i++) fs[i, i]=i*10;
for(int i=0; i < 6; i++) {
x = fs[i, i] ;
if(x != -1) Console.Write (x + " ");
}
Console.WriteLine();