【发布时间】:2013-02-14 18:29:16
【问题描述】:
我正在尝试提取字符串的前 200 个单词,但有时会出现以下错误:
"Index and length must refer to a location within the string. Parameter name: length"
代码是:
int i = GetIndex(fullarticle, 200);
string result = fullarticle.Substring(0, i);
我该如何解决这个问题?
【问题讨论】:
-
你说你想要200字。如果您的字符串少于 200 个单词会怎样?能否展示GetIndex的代码?