> If you create an array using Array.CreateInstance() and use a lower bound >
> 0, you apparently get an array of the wrong type.
Well, sort of.
Internally, .NET has two types of array - "vectors" (single-
dimensional, 0-based) and more general arrays.
When C# uses a single-dimensional array, it *assumes* it's one of these
"vector" types and that's what it really casts it to.
If you need to use a single-dimensional array with a non-zero lower
bound in C#, you need to access it using the Array class (and IList
etc).
> Everything works well in .NET 1.1. So it's apparently a bug introduced in
> .NET 2.0.
Hmm... I thought I'd seen exactly the same behaviour in 1.1...
unfortunately I can't easily test it any more.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Gianluca - 19 Nov 2006 21:24 GMT
Yep. I know about the internal difference between the vector and the array.
And you are right that it doesn't work with .NET 1.1 as well. I was testing
MD arrays and it also works if you cast it in the immediate window.
> > If you create an array using Array.CreateInstance() and use a lower bound >
> > 0, you apparently get an array of the wrong type.
[quoted text clipped - 16 lines]
> Hmm... I thought I'd seen exactly the same behaviour in 1.1...
> unfortunately I can't easily test it any more.