我想选择富文本框文本的最后一个“{”和“}”之间的文本。我有下一个代码,但我在“LastIndexOf”函数上有一个错误,我不知道如何修复它。有人可以给我一些帮助吗?
private void highlightText()
{
mRtbxOperations.SelectionStart = mRtbxOperations.Text.LastIndexOf(@"{", 1, mRtbxOperations.SelectionStart);
mRtbxOperations.SelectionLength = mRtbxOperations.Text.IndexOf(@"}", mRtbxOperations.SelectionStart, mRtbxOperations.Text.Length - 1);
mRtbxOperations.SelectionBackColor = Color.LightBlue;
mRtbxOperations.SelectionFont = new Font(mRtbxOperations.SelectionFont, FontStyle.Underline);
mRtbxOperations.SelectionLength = 0;
}
最后索引错误:
计数必须是正数,并且必须引用字符串、数组或集合中的某个位置。参数名称:计数