Clear multi-dimensional array : Array Multi Dimension « Data Structure « VB.Net






Clear multi-dimensional array

 


Imports System
Imports Microsoft.VisualBasic      

Module Example

    Sub Main()
        Dim numbers2(,) As Integer = {{ 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }}

        For i As Integer = 0 To 2
            For j As Integer = 0 To 2
                Console.WriteLine("{0} ", numbers2(i, j))
            Next j
        Next i

        Array.Clear(numbers2, 2, 5)

        For i As Integer = 0 To 2
            For j As Integer = 0 To 2
                Console.Write("{0} ", numbers2(i, j))
            Next j
        Next i
        Dim numbers3(,,) As Integer = {{{ 1, 2 }, { 3, 4 }}, _
                                       {{ 5, 6 }, { 7, 8 }}, _
                                       {{ 9,10 }, {11,12 }}}

        For i As Integer = 0 To 1
            For j As Integer = 0 To 1
                For k As Integer = 0 To 1
                    Console.Write("{0} ", numbers3(i, j, k))
                Next k
                Console.WriteLine()
            Next j
            Console.WriteLine()
        Next i

        Array.Clear(numbers3, 2, 5)

        For i As Integer = 0 To 1
            For j As Integer = 0 To 1
                For k As Integer = 0 To 1
                    Console.Write("{0} ", numbers3(i, j, k))
                Next k
                Console.WriteLine()
            Next j
            Console.WriteLine()
        Next i
    End Sub
End Module

   
  








Related examples in the same category

1.Initializing a jagged array, one in which the length of each array differsInitializing a jagged array, one in which the length of each array differs
2.Define and initialize the multi-dimensional arrayDefine and initialize the multi-dimensional array
3.Seclare a 4x3 Integer arraySeclare a 4x3 Integer array
4.Array Performance Test: Two-dimensional arrayArray Performance Test: Two-dimensional array
5.Array Performance Test: Two-dimensional Array and SetValue(i, i)Array Performance Test: Two-dimensional Array and SetValue(i, i)
6.Two Dimensional Rectangle ArrayTwo Dimensional Rectangle Array
7.Define and Init two dimensional arrayDefine and Init two dimensional array
8.Initializing multidimensional arrays: rectangular two-dimensional arrayInitializing multidimensional arrays: rectangular two-dimensional array
9.Jagged two-dimensional arrayJagged two-dimensional array
10.Two dimension array DemoTwo dimension array Demo
11.Array.SetValue for two-dimensional array
12.Array.SetValue for three-dimensional array
13.Array.SetValue for a seven-dimensional array