Converting VBScript's LBound Function

Definition: Returns the smallest available subscript for the indicated dimension of an array.

LBound

Typically the lower bound of an array (that is, the index number assigned to the first element in the array) is 0. In Windows PowerShell you can verify that by using the GetLowerBound() method. For example, suppose we use the following command to create an array named $a:

$a = 1,2,3,4,5,6,7,8,9

We can then use this command to determine the lower bound of the array and store that value in the variable $b:

$b = $a.getlowerbound(0)

Note. The parameter 0 passed to GetLowerBound() simply means that we want to look at the first dimension in the array. If we were working with a multi-dimensional array we could supply other values to GetLowerBound().

When you run this command and then echo back the value of $b you should get the following:

0

Return to the VBScript to Windows PowerShell home page