C# program問題:divide a long string into some shot string

2008-11-13 7:01 am
如果我想獎一個長的string 例如," i am a boy" 分做4個string "i" , "am" , "a" "boy",應該點寫?

回答 (1)

2008-11-13 9:45 am
✔ 最佳答案
Use Split() method of System.String class.

string words = "i am a boy";
string[] word = words.Split(new Char[] {' '});

foreach (string s in word)
{
Console.WriteLine(s);
}

http://msdn.microsoft.com/en-us/library/b873y76a.aspx


收錄日期: 2021-04-25 20:33:25
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081112000051KK02082

檢視 Wayback Machine 備份