读书人

split(quot;$quot;)表示遇到$号分解元素么?该

发布时间: 2012-02-08 19:52:21 作者: rapoo

split("$")表示遇到$号分解元素么?
split( "$ ")表示遇到$号分解元素么?

[解决办法]
public string[] Split(params char[] separator)
参数
separator
分隔此实例中子字符串的 Unicode 字符数组、不包含分隔符的空数组或 空引用(在 Visual Basic 中为 Nothing)
用法(c#)
using System;

public class SplitTest {
public static void Main() {

string words = "this is a list of words, with: a bit of punctuation. ";

string [] split = words.Split(new Char [] { ' ', ', ', '. ', ': '});

foreach (string s in split) {

if (s.Trim() != " ")
Console.WriteLine(s);
}
}
}

读书人网 >C#

热点推荐