C#转换为字符字节(十六进制表示) [英] C# Convert Char to Byte (Hex representation)

查看:217
本文介绍了C#转换为字符字节(十六进制表示)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个简单的问题,但我想不出

This seems to be an easy problem but i can't figure out.

我要这个角色的<转换; 字节(十六进制表示),但如果我用

I need to convert this character < in byte(hex representation), but if i use

byte b = Convert.ToByte('<');



我得到的 60 (十进制表示),而不是 3C

i get 60 (decimal representation) instead of 3c.

推荐答案

60 == 0x3C符号

您已经有你正确的答案,但你在错误的方式看它。

You already have your correct answer but you're looking at it in the wrong way.

0X 是十六进制的前缀结果
3C 为3×16 + 12

0x is the hexadecimal prefix
3C is 3 x 16 + 12

这篇关于C#转换为字符字节(十六进制表示)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆