Some context: I'd like to write a class where the main method for adding things to a collection is through a method (or methods) that are named Add (or something like that). And so the signature that seems best is params object[]. Internally, this very function would have to switch/if-else all the types that it can accept. So, initially it could accept this object[] array, but I might like to see it also accept object[][], and object[][][], etc, and then the method/function could flatten internally, so the user wouldn't need to do that prior to calling this function.
So...
Is it possible to write a function that can accept various Levels of List types for a single kind of object? As a side question, when designing an interface to a class, which is better to accept (Edit: struck from the question because there is already enough going on.)object[]
or IEnumerable<object>
or params object[]
?
For instance, I'm thinking of a function that accepts both/all of object[]
, IEumerable<object>
, and possibly further nesting like: IEnumerable<IEnumerable<object>>
, object[][]
(and on, on and on, etc).
Is this possible?