本文介绍了使用逗号分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图从
I am trying to get four stings from
His duty to write a computer program, he did not do it very well, I gave him a score of 5, I hope he do better next time.
string one = His duty to write a computer program
string two = he did not do it very well
string three = I gave him a score of 5
string four = I hope he do better next time
the length of the string will vary that is why I am using the comma(,) to know where to split it.
我尝试过:
What I have tried:
string edit;
edit = LBDuties.SelectedValue.ToString();
string[] Duties;
Duties = edit.Substring();
推荐答案
string s = "His duty to write a computer program, he did not do it very well, I gave him a score of 5, I hope he do better next time.";
string[] sentences = s.Split(',');
foreach (string sentence in sentences) {
Console.WriteLine(sentence);
}
输出:
他有责任写一个电脑程序
他没有这样做很好
我给了他5分
我希望他下次能做得更好。
Output:
His duty to write a computer program
he did not do it very well
I gave him a score of 5
I hope he do better next time.
这篇关于使用逗号分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!