我从四个不同的页面和不同的域中获取数据。
1- .com
2- .co.uk
3- .ca
4- .co.jp
对于以上所有内容,我从Html中获取数字并使用line将其转换为Double:
string lowestSellerPrice = (Convert.ToDouble(fbalPrice) +
Convert.ToDouble(fbalsPrice)).ToString();
这适用于前3个域,但对于.co.jp,即使fbalPrice
和fbalsPrice
中始终有一个数字,它总是给出异常:
Input string was not in a correct format
任何建议,因为我一直在努力解决这个问题太长时间没有结果我也尝试了try parse
解决方案,但没有运气。
更新
见:
答案 0 :(得分:0)
字符串就像" 1234"和" 111"然后我做了替换("",""); 。只有数字解除这个但是没有用,所以我做了这个:
if (fbalPrice.Contains(" "))
{
fbalPrice = fbalPrice.Remove(0, fbalPrice.IndexOf(" ") + 1).Replace(",","").Trim();
}
if(fbalsPrice.Contains(" "))
{
fbalsPrice = fbalsPrice.Remove(0, fbalsPrice.IndexOf(" ") + 1).Replace(",", "").Trim();
}
然后添加它们并且它有效。