byte[] pszBufIn=new byte[256]
我有两字符串
string str ="上海";
string str2="北京";我要实现这样的功能,
前六个字节显示上海,不足的补零
pszBufIn[0]=0xc9
pszBufIn[1]=0xcf
pszBufIn[2]=0xba
pszBufIn[3]=0xa3
pszBufIn[4]=0x00
pszBufIn[5]=0x00
然后我从第六个字节显示 str2的内容
pszBufIn[6]=0xxx
pszBufIn[7]=0xxx
pszBufIn[8]=0xxx
pszBufIn[9]=0xxx
pszBufIn[10]=0x00
pszBufIn[11]=0x00
.................. 谢谢
我有两字符串
string str ="上海";
string str2="北京";我要实现这样的功能,
前六个字节显示上海,不足的补零
pszBufIn[0]=0xc9
pszBufIn[1]=0xcf
pszBufIn[2]=0xba
pszBufIn[3]=0xa3
pszBufIn[4]=0x00
pszBufIn[5]=0x00
然后我从第六个字节显示 str2的内容
pszBufIn[6]=0xxx
pszBufIn[7]=0xxx
pszBufIn[8]=0xxx
pszBufIn[9]=0xxx
pszBufIn[10]=0x00
pszBufIn[11]=0x00
.................. 谢谢
byte[] tmpArray;
string[] str =new string[3]{"上海","北京","成都"};
for (int i=0;i<3;i++)
{
tmpArray=System.Text.Encoding.GetEncoding("gb2312").GetBytes(str[i]);
string s=pszBufIn[0].ToString("X");
Array.Copy(tmpArray,0,pszBufIn,6*i,4);
}
byte[] a = null;
a = System.Text.Encoding.Unicode.GetBytes("上海");
System.Array.Copy(a, 0, all, 0, 4);a = System.Text.Encoding.Unicode.GetBytes("北京");
System.Array.Copy(a, 0, all, 6, 4);