What exception to throw when sequence lengths do not match

I re-executed Enumerable.Zip(mine is called Merge). This is the same as the original, except that if one enumerator MoveNextreturns false before the other (indicating that the sequences do not have the same length), it throws an exception.

My question is: what would be the most suitable exception from BCL to throw here? (I want this to closely simulate the rest of the functions Enumerable(LINQ).)

+5
source share
1 answer

I think since your second array will be an argument. So

System.ArgumentOutOfRangeException

ArgumentException, , ( ) . , , .

System.InvalidOperationException

, , - . , .

+3