gpt4 book ai didi

c# - 将整数转换为字节

转载 作者:行者123 更新时间:2023-12-02 05:19:58 25 4
gpt4 key购买 nike

我有 C# 程序。我想将 int 转换为十六进制,然后将其转换为字节。但是第三行有问题:

int i = 10;
string str = i.ToString("X");
byte b = Convert.ToByte(str);

请帮助我。

最佳答案

byte b = byte.Parse(str, NumberStyles.AllowHexSpecifier);

关于c# - 将整数转换为字节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2265817/

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