STRING TO HEX如何添加向量ob字节?

时间:2022-12-26 15:46:50

I have the following code:

我有以下代码:

string s =   "2563MNBJP89256666666685755854";            Byte[] bytes = encoding.GetBytes(s);            string hex = "";            foreach (byte b in bytes)            {                int c=b;                hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(c.ToString()));            }

It prints the hex values . How can I add it in a vector ob bytes like this?

它打印十六进制值。如何将它添加到像这样的向量ob字节中?

new byte [0x32,0x35..]

In hex I have : 323536....and so on. The next step is to add then in a byte[] vector in the following format 0x32,0x35..and so on; How to do this?

在十六进制中我有:323536 ....等等。下一步是在byte []向量中添加以下格式0x32,0x35 ..依此类推;这个怎么做?

THX

谢谢

4 个解决方案

#1


1  

Isn't bytes already the list of bytes you want?

不是字节已经是你想要的字节列表吗?

#2


0  

C#: System.Text.Encoding.ASCII.GetBytes("test")

C#:System.Text.Encoding.ASCII.GetBytes(“test”)

#3


0  

For C# you could try

对于C#你可以尝试

System.Text.ASCIIEncoding  encoding=new System.Text.ASCIIEncoding();Byte[] bytes = encoding.GetBytes(strVar);//strVar is the string variable

#4


0  

in C# you can use Encoding.GetBytes Method

在C#中,您可以使用Encoding.GetBytes方法

#1


1  

Isn't bytes already the list of bytes you want?

不是字节已经是你想要的字节列表吗?

#2


0  

C#: System.Text.Encoding.ASCII.GetBytes("test")

C#:System.Text.Encoding.ASCII.GetBytes(“test”)

#3


0  

For C# you could try

对于C#你可以尝试

System.Text.ASCIIEncoding  encoding=new System.Text.ASCIIEncoding();Byte[] bytes = encoding.GetBytes(strVar);//strVar is the string variable

#4


0  

in C# you can use Encoding.GetBytes Method

在C#中,您可以使用Encoding.GetBytes方法