【问题标题】:Additional non-parsable characters are at the end of the string其他不可解析的字符位于字符串的末尾
【发布时间】:2014-05-03 06:04:10
【问题描述】:

我正在做以下从字符串到整数的转换,

Convert.ToInt32("10D6DE", 16) -> works fine

but,

Convert.ToInt32("D0437X", 16) -> throws an format exception,
 "Additional non parsable characters at the end of string"

我不确定出了什么问题。

【问题讨论】:

  • “我不确定怎么了。”好吧 Convert.To* 尝试转换整个值,仅此而已。如果您只想转换部分值,则需要计算要转换的部分,然后转换该子字符串。

标签: c# string type-conversion formatexception


【解决方案1】:

hexdigits:从 0 到 f 的十六进制数字序列,或 0 通过 F.

它最后不会解析你的 X。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    • 1970-01-01
    • 2011-12-09
    • 2015-12-17
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多