开发者

STRING TO HEX how to add in a vector ob bytes?

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?

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?

THX


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


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


For C# you could try

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


in C# you can use Encoding.GetBytes Method

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜