I needed to store information in a grid similar to Excel where I did not want
to restrain the user to a fixed multidimensional array that would be mostly
unpopulated. Taking a page from NTFS, I decided to create a sparse array.
This array supports the bulk of those things that are supported by the System.Array
class. Under the hood, it is using a hash table to store the elements with the
index being the key.
Following is an example of how to use the SparseArray
class.
SparseArray array = new SparseArray(2);
array[3, 3] = "Hello";
array[9, 417] = "Nothing";
int b;
b = array.GetLowerBound(0);
b = array.GetLowerBound(1);
b = array.GetUpperBound(0);
b = array.GetUpperBound(1);
b = array.Count;
object o = null;
o = array[3, 3];
o = array[1, 1];
o = array[9, 417];
IEnumerator en = array.GetEnumerator();
while (en.MoveNext())
o = en.Current;
I have been a Windows software developer since 1991. Most of what I create fills the need for some aspect of bigger projects that I consult on.