c# - C# 中的 Int.Parse 抛出格式异常

标签 c# c#-4.0

<分区>

Possible Duplicate:
C# int.parse issue with leading zeros

我如何将其更正为带有前导零的 int。实际上需要忽略/删除 FormatException。

string value = "055";
int x = int.Parse(value);

最佳答案

它在我的系统上运行良好。

enter image description here

可能是当前文化的问题,你可以试试

string value = "055";
int x = int.Parse(value, CultureInfo.InvariantCulture);

关于c# - C# 中的 Int.Parse 抛出格式异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11877688/

相关文章:

c# - 如何将字符串映射到自动映射器中的日期?

c# - 外部客户端无法访问 Azure Service Fabric 上的 WCF 通信监听器

linq - 尝试使用表达式树过滤 Nullable 类型

c# - 在 .Net 2.0 项目中创建扩展方法,使用 C# 4.0 进行编译

c# - 在word自动化中设置列宽抛出异常

C# 传递一个值到一个新的表单

c# - 带有 .Net Core 2.1 的 HttpClient 挂起

c# - 在 MS VS Express 2012 中使用 Microsoft.Office

c# - C# List<T> 中元素的顺序是否确定?

c# - 如何测试 SSL/TLS 底层是否正常工作