I think this is kind of what you want; if it's not, I'd be curious to hear from you:
public class IndexedArray
{
public bool[,,] A2 { set; get; }
public bool progressMade { set; get; }
public List<int> lastChangedIndexes { set; get; }
public IndexedArray(int d1, int d2, int d3)
{
progressMade = false;
A2 = new bool[d1,d2,d3];
lastChangedIndices = new List<int>();
}
public bool this[int x, int y, int z]
{
get { return A2[x, y, z]; }
set
{
progressMade = A2[x, y, z] != value;
if (progressMade)
{
lastChangedIndices .Add(x);
lastChangedIndices .Add(y);
lastChangedIndices .Add(z);
A2[x, y, z] = value;
}
}
}
}
Test:
IndexedArray testArrayProp = new IndexedArray(3, 4, 5);
testArrayProp[1, 2, 3] = true;
bool check = testArrayProp[1, 2, 3];
var changedIndices = testArrayProp.LastChangedIndices;
I would not use this type of solution to the problem of how you manage an Array, and keep track of change ... if that's what you are really after here.
Of course, you can't inherit from 'Array, or use 'Array as a constraint in a Generic Class, because Array is sealed. Depending on the circumstances I would go for using Lists.
At the point you wanted to dynamic notifications of changes, you could implement INotifyPropetyChanged, rather than use the non-dynamic tracking variables used here.