Question

as I am implementing the ICollection-Interface in my class I want to implement the CopyTo-Method and I have to throw an Argument-exception if the array is multidimensional. What is meant by this? The head of my method is this

public void CopyTo(MyClass[] array, int arrayIndex)

I thought these brackets would mean that the given array is one-dimensional but when I automatically import the comments from the Interface the comment appears, that I have to check for multidimensionality. Can someone explain it to me?

With kind regards

Sebastia

Was it helpful?

Solution

You can look at Array.Rank? However, T[] is one dimensional. You mainly need to check the rank when all you know is "Array". This is because the actual method is exposed via Array, not T[].

So in short - don't worry about it in this scenario ;-p

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top