我RichTextBox在几种方法中使用实例,这些方法正在更改字体、颜色、将图像转换为 Rtf 格式。
public static string ColorText(string text)
{
System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox();
rtb.Text = conversation;
// find predefined keywords in text, select them and color them
return rtb.Rtf;
}
过了一会儿,我得到了OutOfMemory异常。我应该打电话rtb.Dispose();吗?或GC.Collect或使用using或什么是正确的方法?