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.
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.
解决方案 »
- sql语句问题。望高手解惑!
- 关于XML问题 我现在丛数据库某一个字段取出一个字符串是XML格式的
- [winform]DataGridView如何一边加载数据一边显示进度条?
- 困扰我很长时间的问题!你们的datagrid都是怎么样实现单选的?
- 急!!!请高手指点一下,感激不尽!
- 清理注册表中冗余软件信息的问题
- C#实现数据库里的数据上传
- ADO.NET多数据库事务问题?
- 如何实现获取数据库表中的新增数据?
- 在dataGrid1_DoubleClick中调用dataGrid1_MouseDown事件,通过代码怎样用???
- c#动态创建winfom窗体
- VS2008下windows应用程序编译成dll
如果控制台程序,你也可以空格来截取字符串。
String[] DivideSentence(String STR)
{
return STR.Split(' ');
}
protect string[] DivideSentence(string msg)
{
return msg.Split(' ');
}
string[] str = msg.split(' ');//用split(' ')分 然后分别是
string str1 = str[0];
string str2 = str[1];
...............//接着用吧
{
return msg.Split(' ');
}