在C#中,使用初始化語法,我可以說:是否可以使用C#初始化語法來傳遞參數?
string[] mystrings = {"one", "two", "three"};
是否有可能使用相同的數組初始化語法轉換這樣的:
string test = "This is a good sentance to split, it has at least one split word to split on.";
string[] mystrings = test.Split(new string[] { "split" }, StringSplitOptions.RemoveEmptyEntries);
弄成這個樣子:
string test = "This is a good sentance to split, it has at least one split word to split on.";
string[] mystrings = test.Split({ "split" }, StringSplitOptions.RemoveEmptyEntries);
它似乎應該工作,但我不能讓它做任何事情。
嘿,那是什麼! – 2010-07-07 16:29:34
是的,'字符串'較少鍵入:-) – 2010-07-07 16:30:22
這就是答案。 :) – 2010-07-07 16:30:56