在学习中我们要善于总结,总结对我们有很大的帮助,可以加快我们学习的步伐。在这里我给大家总结一下关于VB.NET Split使用方法,希望朋友们在工作学习中总结出更多的方法。

VB.NET Split使用方法一. 简单的split分割字符串

首先我们拿了一个带多个空格的字符串来做分割. 我们分配一个New Char() array 保存为String() array 来储存我们例子中的那些分割后的单词.最后,我们用loop循环来遍历和显示这些分割后的字母集合.

 
  
  1. === Program that uses Split on String (VB.NET) ===  

  2. Module Module1  

  3. Sub Main()  

  4. ' We want to split this input string  

  5. Dim s As String = "Our website address is www.51cto.cn"

  6. ' Split string based on spaces  

  7. Dim words As String() = s.Split(New Char() {" "c})  

  8. ' Use For Each loop over words and display them  

  9. Dim word As String  

  10. For Each word In words  

  11. Console.WriteLine(word)  

  12. Next  

  13. End Sub  

  14. End Module

  15. === Output of the program ===  

  16. Our   

  17. website   

  18. address   

  19. is  

VB.NET Split使用方法二. 分割一个完整文件路径

 
  
  1. Here we see how you can Split a file system path into separate parts us