views:

141

answers:

2

Hello,

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

+2  A: 

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

Marc Gravell
The interface signature for ICollection<T> is actually CopyTo(T[]array,int arrayIndex) and the ICollection comments tells you to check for multidimension arrays so this must mean that T[] is not a constraint for single dimension arrays. Are you sure about this?
TT
A: 

ok I also discussed with some more people about it and we all think that ICollection is not really good documented ^^

Xelluloid