Home > Enterprise >  Whats the use of GetLowerBound()?
Whats the use of GetLowerBound()?

Time:06-01

The lowerbound of an array is always zero in VB.net, even if the first element is set to Nothing. So why do we need to use GetLowerBound(dimension) to get the index of the first element of an array in a particular dimension?

CodePudding user response:

As per documentation found here: https://docs.microsoft.com/en-us/dotnet/api/system.array.getlowerbound?view=net-6.0

There can be arrays that do not start with index 0:

Note that, although most arrays in .NET are zero-based (that is, the GetLowerBound method returns zero for each dimension of an array), .NET does support arrays that are not zero-based. Such arrays can be created with the CreateInstance(Type, Int32[], Int32[]) method, and can also be returned from unmanaged code.

  • Related