Replace the data into byte[]

1. Int32 is replaced by Byte[] (  fixed to occupy 4 bytes )

int count=10000;

byte[] data= BitConverter.GetBytes(count);

BitConverter.ToInt32(data);//Convert Byte[] to Int

 

2. Replace string with Byte[] (the number of bytes occupied is related to the length of sting, a single letter or number occupies 1 byte, and a single Chinese character occupies 2 bytes )

string count="10000";

byte[] data= Encoding.UTF8.GetBytes(count);

Guess you like

Origin blog.csdn.net/a451319296/article/details/108412486