c++
char *func(unsigned char buf, int buflen);
对应的c#
byte[] func(byte[] buf, int buflen);
然后byte[] str = new byte[xxx];
str = func(buf, buflen);
---------------------------------------------
c# string和byte[]转换
byte[] byteArray = System.Text.Encoding.Default.GetBytes( str );
反过来也是一样,把byte[]转成string:
string str = System.Text.Encoding.Default.GetString( byteArray );
其实,在System.Text.Encoding class中,还有很多其它有用的方法,像GetChars,从一个byte[]转成一个char[],等等,可以参考MSDN。
另外,还有其它编码方式的,如System.Text.UTF8Encoding class、System.Text.UnicodeEncoding class等,根据不同需要可选不同的class。
追问我现在已经得到了byte流 转换为Image之后 直接报错。。 是不是流不对
追答转换为Image 是什么意思? 报什么错?
请把c++的原型和你要做的操作说明下, 这样才能理解你的意思,做更好的解答