`
cloudtech
  • 浏览: 4612508 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

浅谈string.split()方法

 
阅读更多

最近在项目组里锻炼,天天都有一些新的方法和感受,由于本人的文笔不是很好,尽量努力把他们记录下来,毕竟好记性不如赖笔头嘛!现在写一下给大家分享:(三种常见的用法)

1Split(array<Char>[]()[]) Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array.(返回一个由给定的字符串分割的子字符串)

2Split(array<Char>[]()[], Int32) Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array. A parameter specifies the maximum number of substrings to return.(返回由给定的字符串(第一个参数)分割的子字符串,第二个参数规定子串的最大长度。)

3Split(array<Char>[]()[], StringSplitOptions) Returns a string array that contains the substrings in this string that are delimited by elements of a specified Unicode character array. A parameter specifies whether to return empty array elements.(返回由给定的字符串分割的子字符串,第二个参数包括两个成员:None(返回的子字符串里包括空格),RemoveEmptyEntries(返回的子字符串里不包括空格))

下面是一个小例子:

string s="abcdeabcdeabcde";

string[] sArray=s.Split('c');

foreach(string i in sArray)

Console.WriteLine(i.ToString());

以上内容来自MSDN.希望大家能够喜欢!

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics