Android Question Getting the length of a multi-dimensional array

Discussion in 'Android Questions' started by wonder, Jun 6, 2015.

  1. wonder

    wonder Expert Licensed User

    So I have the following (x, y) array:
    Code:
    Dim MyArray(10, number_of_elements) as Int
    Where the number of elements is defined by the user.

    When using the MyArray.Lenght property, I get the number 10.
    How to get the lenght of the array's Y dimension through .lenght?
     
  2. eurojam

    eurojam Well-Known Member Licensed User

    Try
    Code:
    Dim MyArray(1020As Int
    Dim r As Reflector
    Dim dims(0As Int
    r.Target = MyArray
    dims = r.TargetRank
    Log("array dimension: " & dims.Length & " Bounds " & dims(0) & " " & dims(1))
     
    wonder, Peter Simpson and DonManfred like this.
  3. wonder

    wonder Expert Licensed User

    eurojam likes this.
  4. eurojam

    eurojam Well-Known Member Licensed User

    Wonder,
    there is no magic within this code. It uses the possibility of java called reflection which let you examine java classes at runtime, but this you already knows. And it is not my code, "big brother" google found it for me....but thanks for the honor;)

    stefan
     
    wonder and DonManfred like this.
Loading...