-7

我正在尝试创建一个句子计数功能,但我面临以下错误。我应该将数据类型更改为什么?

private int SplitSentences(string fbStatus)
        {
            int splitSentences = Regex.Split(fbStatus, @"(?<=['""A-Za-z0-9][\.\!\?])\s+(?=[A-Z])");
            label_totalsentencecount.Text = splitSentences.ToString();
            return splitSentences;

        }
4

1 回答 1

3

该方法应阅读

private int SplitSentences(string fbStatus)
{
    string[] splitSentences = Regex.Split(fbStatus, @"(?<=['""A-Za-z0-9][\.\!\?])\s+(?=[A-Z])");
    label_totalsentencecount.Text = splitSentences.Length.ToString();
    return splitSentences.Length;
}

的类型splitSentencesstring[],您要在其中返回长度而不是实际的句子集。

于 2013-07-23T04:53:17.193 回答