Xamarin.forms 如何从字符串中生成双精度

Xamarin.forms 如何从字符串中生成双精度,xamarin.forms,Xamarin.forms,我的用户从不将值添加到弹出窗口中,我在最后添加.0,但一旦我将值转换为双倍,该值将被编辑为仅2,我需要值2.0 if (pResult.Ok && !string.IsNullOrWhiteSpace(pResult.Text)) { var test = pResult.Text + ".0"; double doub = Convert.T

我的用户从不将值添加到弹出窗口中,我在最后添加.0,但一旦我将值转换为双倍,该值将被编辑为仅2,我需要值2.0

if (pResult.Ok && !string.IsNullOrWhiteSpace(pResult.Text))
            {
                var test = pResult.Text + ".0";
              
                double doub = Convert.ToDouble(test);
                _settingsService.TimeOutIdentification = doub;
            }

请使用以下代码进行转换

string str1=string.Format(“{0:F}”,test)


var test=preslt.Text+“.0”;string str=string.Format(“{0:F}”,test);double doub=Convert.ToDouble(str)_设置service.TimeOutIdentification=doub;public double TimeOutIdentification{get=>AppSettings.GetValueOrDefault(nameof(TimeOutIdentification),double.MinValue);set=>AppSettings.AddOrUpdateValue(nameof(TimeOutIdentification),value);}如果要将双精度值2设置为TimeOutIdentification,这是可行的,如果您想向用户输出2.0值,只需添加
String.Format(“{0:F}”,test)