gpt4 book ai didi

c# - 为什么 "0x5"没有被解析为有效的十六进制数?

转载 作者:太空宇宙 更新时间:2023-11-03 19:39:16 29 4
gpt4 key购买 nike

<分区>

我正在尝试检查字符串是否包含有效的十六进制数。

我正在使用 Check if string is valid represantion of HEX number 中记录的方法.

使用以下代码:

using System;
using System.Collections.Generic;

public class Program
{
public static void Main()
{
int temp;
bool b = int.TryParse("0x5", System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out temp);
System.Console.Write("{0} : {1}", b, temp);
}
}

我在输出中得到:False : 0

这里有什么问题吗?

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com