"Nathan M" <(E-Mail Removed)> schrieb:
> Using VB 2005, I have a function that returns an array of a certain
> object.
> In certain cases the function should return an array with a length of 0.
> I've found that this works:
>
> Dim child(0) As Object
> Array.Resize(Of Object)(child, 0)
> Return child
>
> If I leave out the middle line, it returns an array with a length of 1,
> the
> object in the array being nothing.
\\\
Dim child(-1) As Object
///
> I'm interested in knowing why this is the case. Why doesn't "Dim child(0)
> as Object" create an array with a length of 0?
'Dim <variablename>(<upper bound>) As <type>'. The resulting array will
have <upper bound> + 1 elements, i.e. 'Dim child(10) As Object' will
construct an array with 11 elements with indices 0, ..., 10.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
|