在学习中我们要善于总结,总结对我们有很大的帮助,可以加快我们学习的步伐。在这里我给大家总结一下关于VB.NET Split使用方法,希望朋友们在工作学习中总结出更多的方法。
VB.NET Split使用方法一. 简单的split分割字符串
首先我们拿了一个带多个空格的字符串来做分割. 我们分配一个New Char() array 保存为String() array 来储存我们例子中的那些分割后的单词.最后,我们用loop循环来遍历和显示这些分割后的字母集合.
=== Program that uses Split on String (VB.NET) ===
Module Module1
Sub Main()
' We want to split this input string
Dim s As String = "Our website address is www.51cto.cn"
' Split string based on spaces
Dim words As String() = s.Split(New Char() {" "c})
' Use For Each loop over words and display them
Dim word As String
For Each word In words
Console.WriteLine(word)
Next
End Sub
End Module
=== Output of the program ===
Our
website
address
is
VB.NET Split使用方法二. 分割一个完整文件路径
Here we see how you can Split a file system path into separate parts us