Visual Basic Join 函数

定义和用法

Join 函数可返回一个由某个数组中一系列子字符串组成的字符串。

语法
  1. Join(list[,delimiter])
参数描述
list必需的。一维数组,其中包含需被连接的子字符串。
delimiter可选的。用于在返回的字符串中分割子字符串的字符。默认是空格字符。

实例

例子 1
  1. Module Module1
  2. Sub Main()
  3. Dim a(4) As String
  4. a(0)="Saturday"
  5. a(1)="Sunday"
  6. a(2)="Monday"
  7. a(3)="Tuesday"
  8. a(4)="Wednesday"
  9. Dim b() As String=Filter(a,"n")
  10. Dim result As String
  11. result = String.Join(" ", b)
  12. Console.WriteLine(result)
  13. End Sub
  14. End Module

输出:

  1. Sunday Monday Wednesday
例子 2
  1. Module Module1
  2. Sub Main()
  3. Dim a(4) As String
  4. a(0)="Saturday"
  5. a(1)="Sunday"
  6. a(2)="Monday"
  7. a(3)="Tuesday"
  8. a(4)="Wednesday"
  9. Dim b() As String=Filter(a,"n")
  10. Dim result As String
  11. result = String.Join(",", b)
  12. Console.WriteLine(result)
  13. End Sub
  14. End Module

输出:

  1. Sunday, Monday, Wednesday

分类导航