【发布时间】:2011-10-13 18:00:03
【问题描述】:
我有一个RichTextBox,看起来像这样:
TEXT NEXT_TEXT 10.505 -174.994 0
TEXT NEXT_TEXT 100.005 174.994 90
TEXT NEXT_TEXT -10.000 -5.555 180
TEXT NEXT_TEXT -500.987 5.123 270
TEXT NEXT_TEXT 987.123 1.000 180
TEXT NEXT_TEXT 234.567 200.999 90
我想用任何内容替换 "." 并将其放入 ListBox...
所以新文件看起来像这样:
TEXT NEXT_TEXT 10505 -174994 0
TEXT NEXT_TEXT 100005 174994 90
TEXT NEXT_TEXT -10000 -5555 180
TEXT NEXT_TEXT -500987 5123 270
TEXT NEXT_TEXT 987123 1000 180
TEXT NEXT_TEXT 234567 200999 90
我想过将这些值乘以 1000,但我不知道如何正确地对字符串进行匹配计算。
所以下一个想法是这样做(但是这不起作用):
// Splits the lines in the rich text boxes
string[] listOneLines = oneRichTextBox.Text.Split('\n');
// Set the selection mode to multiple and extended.
placementOneListBox.SelectionMode = SelectionMode.MultiExtended;
// Shutdown the painting of the ListBox as items are added.
placementOneListBox.BeginUpdate();
// Display the items in the listbox.
foreach (var item in listOneLines)
{
item.Replace(".","");
placementOneListBox.Items.Add(item);
}
// Allow the ListBox to repaint and display the new items.
placementOneListBox.EndUpdate();
- 谁能帮我弄清楚如何替换“.”?
【问题讨论】:
-
string temp = text.Replace(".", "");其中 text 是来自 RTB 的整个文本
标签: c# replace richtextbox