Given a function which accepts a parameter with the following interface:
interface ITest
{
String this[Int32 dataId, Int32 rowId] { get; set; }
}
How can I determine the number of elements in each dimension of the indexer?
For example if a function receives an array one could use the .GetUpperBound method:
Int32 GetSizeOfDimension(Array test, Int32 dimension)
{
return test.GetUpperBound(dimension);
}
I’m trying to do the following:
Int32 GetSizeOfDimension(ITest test, Int32 dimension)
{
// return UBound of test's given dimension
}
You can’t, in the general case. Imagine an indexer which “worked” in every single case except one – which was randomly determined at the start of the program. How would you find that case, other than by brute force?
If you need this information, your interface will have to expose it directly.