vb System.Array.SetValue类(方法)实例源码

下面列出了vb System.Array.SetValue 类(方法)源码代码实例,从而了解它的用法。

作者:VB.NET开发    项目:Syste   
Public Class SamplesArray

   Public Shared Sub Main()

      ' Creates and initializes a one-dimensional array.
      Dim myArr1(4) As [String]

      ' Sets the element at index 3.
      myArr1.SetValue("three", 3)
      Console.WriteLine("[3]:   {0}", myArr1.GetValue(3))


      ' Creates and initializes a two-dimensional array.
      Dim myArr2(5, 5) As [String]

      ' Sets the element at index 1,3.
      myArr2.SetValue("one-three", 1, 3)
      Console.WriteLine("[1,3]:   {0}", myArr2.GetValue(1, 3))


      ' Creates and initializes a three-dimensional array.
      Dim myArr3(5, 5, 5) As [String]

      ' Sets the element at index 1,2,3.
      myArr3.SetValue("one-two-three", 1, 2, 3)
      Console.WriteLine("[1,2,3]:   {0}", myArr3.GetValue(1, 2, 3))


      ' Creates and initializes a seven-dimensional array.
      Dim myArr7(5, 5, 5, 5, 5, 5, 5) As [String]

      ' Sets the element at index 1,2,3,0,1,2,3.
      Dim myIndices() As Integer = {1, 2, 3, 0, 1, 2, 3}
      myArr7.SetValue("one-two-three-zero-one-two-three", myIndices)
      Console.WriteLine("[1,2,3,0,1,2,3]:   {0}", myArr7.GetValue(myIndices))

   End Sub

End Class

作者:VB程序    项目:Syste   
' 导入命名空间
Imports System


Public Class MainClass

   Shared Sub Main()
        Dim anArray As Array
        Dim l(0) As Integer
        Dim lowerBounds(0) As Integer
        l(0) = 7
        lowerBounds(0) = 1995
        'creates an array of objects numbered 1995 - 2002
        anArray = Array.CreateInstance(GetType(System.Int32), l, lowerBounds)
        anArray.SetValue(200000, 1995)
        anArray.SetValue(1000000, 2001)
        Console.WriteLine("The entry in position 1995 is " & _
        (anArray.GetValue(1995).ToString))
        Console.WriteLine("The entry in position 2002 is " & _
        (anArray.GetValue(2001).ToString))
   End Sub 

End Class


问题


面经


文章

微信
公众号

扫码关注公众号