2013-05-08 183 views

回答

2
string inputString = "Another One Bites The Dust And Another One Down"; 
string[] split = inputString.Split(); 
foreach (string s in split) 
{ 
    Console.Write(s.Substring(0,1)); 
} 
+0

像這樣放 string [] split = inputString.split(); 不要使用下面提到的 string split [] = inputString.split(); – 2013-05-08 10:44:48

1

檢查了這一點:

string s = new string("Any Body Can Dance" 
        .Split(' ') 
        .Select(x => x.First()) 
        .ToArray()); 
Console.WriteLine(s); 
+1

'.Select(d => d.First))。ToArray()'。如果你使用s,編譯器會拋出一個錯誤,因爲s已經定義好了。 +1使用全能的LINQ – Marco 2013-05-08 10:33:52

相關問題