文字列「-4.00%」があります。これを10進数に変換して、変数として宣言し、後で使用できるようにする必要があります。文字列自体はstring[]行にあります。私のコードは次のとおりです。
foreach (string[] row in rows)
{
string row1 = row[0].ToString();
Match rownum = Regex.Match(row1.ToString(), @"\-?\d+\.+?\d+[^%]");
string act = Convert.ToString(rownum); //wouldn't convert match to decimal
decimal actual = Convert.ToDecimal(act);
textBox1.Text = (actual.ToString());
}
これにより、「入力文字列が正しい形式ではありませんでした」という結果になります。何か案は?
ありがとう。