How to use GetValue() method to get the value at the specified position in 1D, 2D and 3D Array in VB.NET

3 Answers

0 votes
Module Module1

    Sub Main()

        Dim arr As String() = {"aaa", "bbb", "ccc", "ddd", "eee"}

        Console.WriteLine("arr(3): {0}", arr.GetValue(3))

    End Sub

End Module

' run:
' 
' arr(3): ddd

 



answered Apr 29, 2016 by avibootz
0 votes
Module Module1

    Sub Main()

        Dim arr As String(,) = {{"aaa", "bbb", "ccc", "ddd"},
                                {"eee", "fff", "ggg", "hhh"}}

        Console.WriteLine("arr(0, 2): {0}", arr.GetValue(0, 2))
        Console.WriteLine("arr(1, 3): {0}", arr.GetValue(1, 3))

    End Sub

End Module

' run:
' 
' arr(0, 2): ccc
' arr(1, 3) : hhh

 



answered Apr 29, 2016 by avibootz
0 votes
Module Module1

    Sub Main()

        Dim arr As String(,,) = {{{"aaa", "bbb", "ccc", "ddd"}, {"eee", "fff", "ggg", "hhh"}, {"eee", "fff", "ggg", "hhh"}},
                                 {{"iii", "jjj", "kkk", "lll"}, {"mmm", "nnn", "ooo", "ppp"}, {"qqq", "rrr", "sss", "ttt"}}}

        Console.WriteLine("arr(0, 2, 1): {0}", arr.GetValue(0, 2, 1))
        Console.WriteLine("arr(1, 2, 3): {0}", arr.GetValue(1, 2, 3))

    End Sub

End Module

' run:
' 
' arr(0, 2, 1): fff
' arr(1, 2, 3): ttt
' 

 



answered Apr 29, 2016 by avibootz
edited Apr 29, 2016 by avibootz
...