我正在转换像41.00027357629127"这样的字符串,我正在使用;
I am converting a string like "41.00027357629127", and I am using;
Convert.ToSingle("41.00027357629127");
或
float.Parse("41.00027357629127");
这些方法返回 4.10002732E+15.
当我转换为浮点数时,我想要41.00027357629127".这个字符串应该是一样的...
When I convert to float I want "41.00027357629127". This string should be the same...
您的线程的语言环境设置为小数点为,"而不是.".
Your thread's locale is set to one in which the decimal mark is "," instead of ".".
试试这个:
float.Parse("41.00027357629127", CultureInfo.InvariantCulture.NumberFormat);
但是请注意,浮点数不能容纳那么多位的精度.您必须使用 double 或 Decimal 才能这样做.
Note, however, that a float cannot hold that many digits of precision. You would have to use double or Decimal to do so.
这篇关于在 C# 中将字符串转换为浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
ASP.NET Core 使用 Azure Active Directory 进行身份验证并ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 进行身
ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用)
ASP Core Azure Active Directory 登录使用角色ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登录使用角色)
如何获取守护进程或服务器到 C# ASP.NET Web API 的How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何获取守护进程或服务器到 C# ASP.N
.Net Core 2.0 - 获取 AAD 访问令牌以与 Microsoft Graph.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 获取 AAD 访问令牌以与 Microsoft Graph 一起使用)
异步调用时 Azure KeyVault Active Directory AcquireTokenAAzure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(异步调用时 Azure KeyVault Active Directory AcquireTokenAsync 超