可能重复:
How to split string preserving whole words?C# - 如何分割字符串
我有以下字符串:
string s = "The Electors shall meet in their respective states to vote by ballot for President and Vice-President.";
我要采取的第一个60个字符,将它们分成两个单独的字符串,每个字符串不超过30个字符每个字符串必须以整个单词开头(不包含部分单词,也不包含空格)。所以这是期望的结果:
string s1 = "The Electors shall meet in"; // 26 characters
string s2 = "their respective states to vot"; // 30 characters
谢谢。
这个问题已经在这里回答了http://stackoverflow.com/questions/4398270/how-to-split-string-preserving-whole-words。 –