Xamarin.forms 如何从字符串中生成双精度
我的用户从不将值添加到弹出窗口中,我在最后添加.0,但一旦我将值转换为双倍,该值将被编辑为仅2,我需要值2.0Xamarin.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
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)当你想把它拿出来的时候,你能告诉我为什么你想把双倍的数值保持在2.0吗?我对此感到困惑,因为这在2.0或2之间是相同的,因为我使用的服务需要双重价值