【发布时间】:2014-04-21 18:45:34
【问题描述】:
我有:
textbox1.text == 1.4087
textbox2.text == 521.54
它不是硬编码的,我是从 JSON 中得到的。无论如何,我想将这两个数字相乘。
我使用这个代码:
double curr = 0.0;
double price = 0.0;
double multiply = 0.0;
double.TryParse(textBox1.Text, out curr);
double.TryParse(textBox2.Text, out price);
multiply = curr * price;
textBox3.Text = multiply.ToString();
我也尝试了Convert.ToDouble 仍然没有运气。
我总是在 textBox3 中得到 0。显然,字符串不被识别为双精度。但他们是。有任何想法吗?谢谢!
编辑:来自 JSON:
{"high": "567.88", "last": "543.95", "timestamp": "1394987785",
我正在使用此代码来获取我需要的内容:
Regex expression = new Regex(@"last"":\s""(?<Identifier>[0-9]+\.[0-9]+)");
var results = expression.Matches(Cryp);
foreach (Match match in results)
{
textBox1.Text = match.Groups["Identifier"].Value;
}
这里有什么问题吗?
【问题讨论】:
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
@JohnSaunders 好的,谢谢!
标签: c# json double type-conversion