转载自:http://www.cnblogs.com/baishahe/archive/2008/03/21/1115919.html

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。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-02-15
猜你喜欢
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-09-14
相关资源
相似解决方案