Visual Basic Join 函数
定义和用法
Join
函数可返回一个由某个数组中一系列子字符串组成的字符串。
语法
Join(list[,delimiter])
参数 | 描述 |
---|---|
list | 必需的。一维数组,其中包含需被连接的子字符串。 |
delimiter | 可选的。用于在返回的字符串中分割子字符串的字符。默认是空格字符。 |
实例
例子 1
Module Module1
Sub Main()
Dim a(4) As String
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
Dim b() As String=Filter(a,"n")
Dim result As String
result = String.Join(" ", b)
Console.WriteLine(result)
End Sub
End Module
输出:
Sunday Monday Wednesday
例子 2
Module Module1
Sub Main()
Dim a(4) As String
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
Dim b() As String=Filter(a,"n")
Dim result As String
result = String.Join(",", b)
Console.WriteLine(result)
End Sub
End Module
输出:
Sunday, Monday, Wednesday