在C#中,有没有提供一种方法,可以将文本转换为二进制,同样要将二进制转换为文本?
解决方案 »
- C#菜鸟,忘大神帮助啊,图形界面问题DataGridView.CellClick 事件
- C# ThreadPool和Thread多线程 问题
- 如何自动确认网页弹出的对话框?
- 如何使用相对路径来复制图片
- 如何实现购物车的一个购买同一个产品多此点击是增加此产品购买的数量而不是现实出来的行数
- 寻找 平台百姓,winner2050 ,两位 ,诚心请教几个问题?顶的有分
- 正则表达式去掉URL中的(http|https|ftp|rtsp|mms)
- 从XML中加载的控件如何设置控件的布局位置呢?
- 一个关于是MouseDown的小问题(最后10分奉上,不够再加)
- 如何把图片转化成二进制数据插到数据库中,然后再显示出来
- 滚动处理问题,在线等
- datagrideview获取当前列数的问题
private string ConvertToString(byte[] thebyte)
{
char[] Chars = new char[System.Text.Encoding.Default.GetCharCount(thebyte, 0, thebyte.Length)];
System.Text.Encoding.Default.GetChars(thebyte, 0, thebyte.Length, Chars, 0);
string newString = new string(Chars);
return newString;
}
//字符串转二进制:
private byte[] ConvertToByte(string theString)
{
byte[] byteStream = System.Text.Encoding.Default.GetBytes(theString);
return byteStream;
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/llddyy123wq/archive/2010/05/16/5597516.aspx
string s = Encoding.GetEncoding("GB2312").GetSt1ring(byte[] xx) 是反向的
private string ConvertToString(byte[] thebyte)
{
char[] Chars = new char[System.Text.Encoding.Default.GetCharCount(thebyte, 0, thebyte.Length)];
System.Text.Encoding.Default.GetChars(thebyte, 0, thebyte.Length, Chars, 0);
string newString = new string(Chars);
return newString;
}
//字符串转二进制:
private byte[] ConvertToByte(string theString)
{
byte[] byteStream = System.Text.Encoding.Default.GetBytes(theString);
return byteStream;
}