在字符串句子中给每个单词加上双引号

 

  1. //在字符串句子中给每个单词加上双引号。    
  2. static void Main(string[] args)          {                   
  3.    string mystring = "This is a test.";                     
  4.    char[] Trimword = { '.'};                
  5.    mystring = mystring.TrimEnd(Trimword);                   
  6.    char[] seprator = {' '};                 
  7.    string[] mywords;                
  8.    mywords = mystring.Split(seprator);                     
  9.    string myresult="";                
  10.    foreach(string myword in mywords)                       
  11.    {                     
  12.      myresult += "\"" + myword + "\"";                
  13.    }                
  14.    Console.WriteLine("The result is {0}.",myresult);                
  15.    Console.ReadKey();            
  16. }