У меня вопрос, почему это происходит. Сначала я объясню, что происходит. Я нахожу строку в RichTextBox
и беру значение Split
и заменяю ее тем же значением, но с десятичным пределом. Вот как выглядит мой файл:
J6 INT-00113G 227.905 174.994 180 SOIC8
J3 INT-00113G 227.905 203.244 180 SOIC8
U13 EXCLUDES 242.210 181.294 180 QFP128
НО по какой-то причине я получаю это, когда пытаюсь заменить и вывести его обратно ... (цифры появляются дважды в 3-м и 4-м столбцах)
J6 INT-00113G 227.91227.91 174.99174.99 180 SOIC8
J3 INT-00113G 227.91227.91 203.24203.24 180 SOIC8
U13 EXCLUDES 242.21242.21 181.29181.29 180 QFP128
И ЗДЕСЬ МОЙ КОД ... ЧТО ОШИБКА, ЧТОБЫ СДЕЛАТЬ ЭТО? ЭТО?
string[] myLines = placementTwoRichTextBox.Text.Split('\n');
foreach (string line in myLines)
{
// Matches the entire line.
Match theMatch = Regex.Match(line, @".*");
if (theMatch.Success)
{
// Stores the matched value in string output.
string output = theMatch.Value;
// Replaces tabs and extra space with only 1 space delimiter
output = Regex.Replace(output, @"\s+", " ");
// Splits the specified regex into two different regexs.
var componentItem = output.Split(' ');
double d1 = Convert.ToDouble(componentItem[2]);
double d2 = Convert.ToDouble(componentItem[3]);
double round1 = Math.Round(d1, 2, MidpointRounding.AwayFromZero);
double round2 = Math.Round(d2, 2, MidpointRounding.AwayFromZero);
componentItem[2] = Regex.Replace(componentItem[2], @".*", round1.ToString());
componentItem[3] = Regex.Replace(componentItem[3], @".*", round2.ToString());
// Sets the RichTextBox to the string output.
newPl2ItemsRichTextBox.AppendText(componentItem[0] + " " + componentItem[1] + " " + componentItem[2] +
" " + componentItem[3] + " " + componentItem[4] + " " + componentItem[5] + "\n");
}
}
Кто-нибудь знает, почему это происходит?