本文整理汇总了VB.NET中System.Array.SetValue方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Array.SetValue方法的具体用法?VB.NET Array.SetValue怎么用?VB.NET Array.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Array 的用法示例。
在下文中一共展示了Array.SetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: SamplesArray
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
开发者ID:VB.NET开发者,项目名称:System,代码行数:39,代码来源:Array.SetValue 输出:
[3]: three
[1,3]: one-three
[1,2,3]: one-two-three
[1,2,3,0,1,2,3]: one-two-three-zero-one-two-three
示例2: MainClass
' 导入命名空间
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
开发者ID:VB程序员,项目名称:System,代码行数:23,代码来源:Array.SetValue
注:本文中的System.Array.SetValue方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论