12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
编程知识 时间:2024-12-04 13:08:17
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
在C#中,split方法是用于将字符串按照指定的分隔符拆分成多个子字符串的功能。一般用法如下:将字符串按照指定的分隔符拆分成字符串数组。可以指定多个分隔符,或者使用字符串数
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
在C#中,split方法是用于将字符串按照指定的分隔符拆分成多个子字符串的功能。一般用法如下:
示例代码如下:
string sentence = "Hello,world";string[] words = sentence.Split(',');// words = {"Hello", "world"}string sentence2 = "apple,banana;orange";string[] words2 = sentence2.Split(new char[] { ',', ';' });// words2 = {"apple", "banana", "orange"}string sentence3 = "one two three four five";string[] words3 = sentence3.Split(new char[] { ' ' }, 3);// words3 = {"one", "two", "three four five"}string sentence4 = "apple, ,banana, ,orange";string[] words4 = sentence4.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);// words4 = {"apple", "banana", "orange"}
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19