本文整理汇总了VB.NET中System.Array.Clone方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Array.Clone方法的具体用法?VB.NET Array.Clone怎么用?VB.NET Array.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Array 的用法示例。
在下文中一共展示了Array.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: SamplesArray
' 导入命名空间
Imports System.Globalization
Public Class SamplesArray
Public Shared Sub Main()
' Create and initialize a new CultureInfo array.
Dim ci0 As New CultureInfo("ar-SA", False)
Dim ci1 As New CultureInfo("en-US", False)
Dim ci2 As New CultureInfo("fr-FR", False)
Dim ci3 As New CultureInfo("ja-JP", False)
Dim arrCI() As CultureInfo = {ci0, ci1, ci2, ci3}
' Create a clone of the CultureInfo array.
Dim arrCIClone As CultureInfo() = CType(arrCI.Clone(), CultureInfo())
' Replace an element in the clone array.
Dim ci4 As New CultureInfo("th-TH", False)
arrCIClone(0) = ci4
' Display the contents of the original array.
Console.WriteLine("The original array contains the following values:")
PrintIndexAndValues(arrCI)
' Display the contents of the clone array.
Console.WriteLine("The clone array contains the following values:")
PrintIndexAndValues(arrCIClone)
' Display the DateTimeFormatInfo.DateSeparator for the fourth element in both arrays.
Console.WriteLine("Before changes to the clone:")
Console.WriteLine(" Original: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCI(3).Name, arrCI(3).DateTimeFormat.DateSeparator)
Console.WriteLine(" Clone: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCIClone(3).Name, arrCIClone(3).DateTimeFormat.DateSeparator)
' Replace the DateTimeFormatInfo.DateSeparator for the fourth element in the clone array.
arrCIClone(3).DateTimeFormat.DateSeparator = "-"
' Display the DateTimeFormatInfo.DateSeparator for the fourth element in both arrays.
Console.WriteLine("After changes to the clone:")
Console.WriteLine(" Original: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCI(3).Name, arrCI(3).DateTimeFormat.DateSeparator)
Console.WriteLine(" Clone: The DateTimeFormatInfo.DateSeparator for {0} is {1}.", arrCIClone(3).Name, arrCIClone(3).DateTimeFormat.DateSeparator)
End Sub
Public Shared Sub PrintIndexAndValues(myArray As Array)
Dim i As Integer
For i = myArray.GetLowerBound(0) To myArray.GetUpperBound(0)
Console.WriteLine(vbTab + "[{0}]:" + vbTab + "{1}", i, myArray.GetValue(i))
Next i
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System,代码行数:52,代码来源:Array.Clone 输出:
The original array contains the following values:
[0]: ar-SA
[1]: en-US
[2]: fr-FR
[3]: ja-JP
The clone array contains the following values:
[0]: th-TH
[1]: en-US
[2]: fr-FR
[3]: ja-JP
Before changes to the clone:
Original: The DateTimeFormatInfo.DateSeparator for ja-JP is /.
Clone: The DateTimeFormatInfo.DateSeparator for ja-JP is /.
After changes to the clone:
Original: The DateTimeFormatInfo.DateSeparator for ja-JP is -.
Clone: The DateTimeFormatInfo.DateSeparator for ja-JP is -.
示例2: Tester
Public Class Tester
Public Shared Sub Main
Dim arrayA() As String = {"One", "Two", "Three", "Four", "Five", "Six"}
Console.WriteLine(Join(arrayA, ","))
Dim arrayB() As String = {"A", "B", "C", "D", "E", "E", "F", "G", "H"}
Console.WriteLine(Join(arrayB, ","))
' ----- Make a reference copy.
Dim arrayC() As String = arrayA
Console.WriteLine(Join(arrayC, ","))
' ----- Make a full, unique copy of all elements.
Dim arrayD() As String = arrayA.Clone
Console.WriteLine(Join(arrayD, ","))
End Sub
End Class
开发者ID:VB程序员,项目名称:System,代码行数:19,代码来源:Array.Clone
注:本文中的System.Array.Clone方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论