Tuesday, September 22, 2009

How to get the Upper Bound of an Array in C#

hi, if you'r using asp, vbscript and all then you have option call UBound
which will return a UpperBound value of Array. but on C#, you dont have that option call Ubound ,for that you can use GetUpperBound() option - Gets the upper bound of the specified dimension in the Array.

here is an Example which can show how to use GetUpperBound()


For i = MyArray.GetLowerBound(0) To MyArray.GetUpperBound(0)

Next i


like this way you can use both option call GetLowerBound & GetUpperBound ,
GetLowerBound will return lower bound value.here you have to pass (int value)
0 - 1st arrayvalue, 1- 2ndarrayvalue like that,

thank you.

No comments:

Post a Comment