在字符串句子中给每个单词加上双引号
- //在字符串句子中给每个单词加上双引号。
- static void Main(string[] args) {
- string mystring = "This is a test.";
- char[] Trimword = { '.'};
- mystring = mystring.TrimEnd(Trimword);
- char[] seprator = {' '};
- string[] mywords;
- mywords = mystring.Split(seprator);
- string myresult="";
- foreach(string myword in mywords)
- {
- myresult += "\"" + myword + "\"";
- }
- Console.WriteLine("The result is {0}.",myresult);
- Console.ReadKey();
- }