C# Convert.Double(字符串)工作错误

C# Convert.Double(字符串)工作错误,c#,.net,string,double,C#,.net,String,Double,我试图通过串口从梅特勒-托莱多称重机读取一些重量值。当我把我从串口得到的字符串转换成双倍时,它会把点放错地方。它将144.95转换为14495.0。如何将此字符串转换为正确的双精度值 if (this.InvokeRequired) { // Using this.Invoke causes deadlock when closing serial port, // and BeginInvoke is good practice anyway. this.BeginI

我试图通过串口从梅特勒-托莱多称重机读取一些重量值。当我把我从串口得到的字符串转换成双倍时,它会把点放错地方。它将144.95转换为14495.0。如何将此字符串转换为正确的双精度值

if (this.InvokeRequired)
{
    // Using this.Invoke causes deadlock when closing serial port, 
    // and BeginInvoke is good practice anyway.
    this.BeginInvoke(
        new EventHandler<SerialDataEventArgs>(spManager_NewSerialDataRecieved), 
        new object[] { sender, e });
    return;
}
string pattern = @"\s.(\d+\.\d{2})(\sg\r\n(S\sS\s.)?)?$";
string data = Encoding.ASCII.GetString(e.Data);
MatchCollection mc = Regex.Matches(data, pattern);
if (mc.Count > 0)
{
    if (tartim)
    {
        double weight = Convert.ToDouble(mc[0].Groups[1].Value); //Wrong conversion
        if (weight > weightLowerLimit && weight < weightUpperLimit)
        {
            MoveToNextSlot();
        }
    }
}
if(this.invokererequired)
{
//使用此.Invoke会在关闭串行端口时导致死锁,
//不管怎样,BeginInvoke是一种很好的实践。
这是我的开始(
新事件处理程序(spManager_NewserialDataReceived),
新对象[]{sender,e});
回来
}
字符串模式=@“\s.(\d+\.\d{2})(\sg\r\n(s\sS\s.)?)?$”;
字符串数据=Encoding.ASCII.GetString(e.data);
MatchCollection mc=Regex.Matches(数据、模式);
如果(mc.Count>0)
{
如果(塔尔蒂姆)
{
double weight=Convert.ToDouble(mc[0]。组[1]。值);//转换错误
如果(重量>重量下限和重量<重量上限)
{
MoveToNextSlot();
}
}
}

Convert.ToDouble(mc[0]。组[1]。值,CultureInfo.InvariantCulture);
mc[0]的值是多少。组[1]。具体值是多少?您的
CurrentCulture
是什么?我认为问题在于您的正则表达式模式。Ulugbek Umirovs的答案是正确的。谢谢