I am now designing an SNMP library. The problem is caused by a special function like this,
*** GetTable(string id)
This function may return Variable[,] which is a two dimensional array sometimes, but also Variable[,,] and arrays with more dimensions. So I believe it is not reasonable to return fixed array such as Variable[,], Variable[,,] and so on.
But what should this method return then? How to design it? What about a custom VariableCollection?
Any suggestion is welcome.
As a general rule, returning a custom type allows for greater flexibility in the representation of your data. I’d also favour providing your own methods for accessing the data in this collection, rather than exposing multidimensional arrays.
I generally avoid using multidimensional rectangular arrays myself. In many cases, multidimensional jagged arrays are more convenient as you can lift a slice out in isolation.