Write a piece of code, it should be able to split a English sentence to
a list of strings. Then test your code with a test code.
(编写一段程序,使得你的程序可以将一段英语按空格拆分成一组字符串。编写一度
代码来测试你的程序。)例:假设你的方法如下:public static string[] DivideSentence(string msg);当以如下方式调用该方法时
string msg = "The fox jump over the log.";
string[] segs = DivideSentence(msg);
foreach(string s in segs)
{
   Console.WriteLine(s);
}控制台输出结果为:
The
fox
jump 
over 
the 
log.

解决方案 »

  1.   

    如果是空间输入的话,用keyup事件,判断e.KeyCode。
    如果控制台程序,你也可以空格来截取字符串。
      

  2.   


    String[] DivideSentence(String STR)
    {
        return STR.Split(' ');
    }
      

  3.   

    最快 string[] segs=msg.Split(" ".ToArray(), StringSplitOptions.RemoveEmptyEntries);
      

  4.   


    protect string[] DivideSentence(string msg)
    {
      return msg.Split(' ');
    }
      

  5.   


    string[] str = msg.split(' ');//用split(' ')分 然后分别是 
    string str1 = str[0];
    string str2 = str[1];
    ...............//接着用吧
      

  6.   

    public static string[] DivideSentence(string msg) 
    {   
    return msg.Split(' ');