代碼中出現(xiàn)的sidle是我的網(wǎng)名。

/**//* * @author wuerping * @version 1.0 * @date 2004/11/30 * @description: */ using system; using system.text; namespace sidlehelper " /> 国产亚洲欧美ai在线看片,一久久,精品96在线观看影院

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

C#中string與byte[]的轉(zhuǎn)換幫助類(lèi)-.NET教程,C#語(yǔ)言

 
主要實(shí)現(xiàn)了以下的函數(shù) 


代碼中出現(xiàn)的sidle是我的網(wǎng)名。 

/**//* 
* @author wuerping 
* @version 1.0 
* @date 2004/11/30 
* @description: 
*/ 
using system; 
using system.text; 
namespace sidlehelper 

/**//// <summary> 
/// summary description for strhelper. 
/// 命名縮寫(xiě): 
/// str: unicode string 
/// arr: unicode array 
/// hex: 二進(jìn)制數(shù)據(jù) 
/// hexbin: 二進(jìn)制數(shù)據(jù)用ascii字符表示 例 字符1的hex是0x31表示為hexbin是 31 
/// asc: ascii 
/// uni: unicode 
/// </summary> 
public sealed class strhelper 

hex與hexbin的轉(zhuǎn)換#region hex與hexbin的轉(zhuǎn)換 
public static void hexbin2hex(byte[] bhexbin, byte[] bhex, int nlen) 

for(int i=0; i<nlen/2; i++) 

if(bhexbin[2*i] <0x41) 

bhex[i] = convert.tobyte(((bhexbin[2*i] - 0x30)<<4) & 0xf0); 

else 

bhex[i] = convert.tobyte(((bhexbin[2*i] - 0x37)<<4) & 0xf0); 


if(bhexbin[2*i+1] <0x41) 

bhex[i] |= convert.tobyte((bhexbin[2*i+1] - 0x30) & 0x0f); 

else 

bhex[i] |= convert.tobyte((bhexbin[2*i+1] - 0x37) & 0x0f); 



public static byte[] hexbin2hex(byte[] bhexbin, int nlen) 

if(nlen%2 !=0) 
return null; 
byte[] bhex = new byte[nlen/2]; 
hexbin2hex(bhexbin, bhex, nlen); 
return bhex; 

public static void hex2hexbin(byte[] bhex, byte[] bhexbin, int nlen) 

byte c; 
for(int i=0;i<nlen;i++) 

c = convert.tobyte((bhex[i]>>4) & 0x0f); 
if(c < 0x0a) 

bhexbin[2*i] = convert.tobyte(c + 0x30); 

else 

bhexbin[2*i] = convert.tobyte(c + 0x37); 

c = convert.tobyte(bhex[i]&0x0f); 
if(c < 0x0a) 

bhexbin[2*i+1] = convert.tobyte(c + 0x30); 

else 

bhexbin[2*i+1] = convert.tobyte(c + 0x37); 



public static byte[] hex2hexbin(byte[] bhex, int nlen) 

byte[] bhexbin = new byte[nlen*2]; 
hex2hexbin(bhex, bhexbin, nlen); 
return bhexbin; 

#endregion 

數(shù)組和字符串之間的轉(zhuǎn)化#region 數(shù)組和字符串之間的轉(zhuǎn)化 
public static byte[] str2arr(string s) 

return (new unicodeencoding()).getbytes(s); 

public static string arr2str(byte[] buffer) 

return (new unicodeencoding()).getstring(buffer, 0, buffer.length); 


public static byte[] str2ascarr(string s) 

return system.text.unicodeencoding.convert(system.text.encoding.unicode, 
system.text.encoding.ascii, 
str2arr(s)); 


public static byte[] str2hexascarr(string s) 

byte[] hex = str2ascarr(s); 
byte[] hexbin = hex2hexbin(hex, hex.length); 
return hexbin; 

public static string ascarr2str(byte[] b) 

return system.text.unicodeencoding.unicode.getstring( 
system.text.asciiencoding.convert(system.text.encoding.ascii, 
system.text.encoding.unicode, 
b) 
); 


public static string hexascarr2str(byte[] buffer) 

byte[] b = hex2hexbin(buffer, buffer.length); 
return ascarr2str(b); 

#endregion 


AspNet技術(shù)C#中string與byte[]的轉(zhuǎn)換幫助類(lèi)-.NET教程,C#語(yǔ)言,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 三级黄在线播放 | 菠萝菠萝蜜高清观看在线 | 亚洲AV无码专区国产乱码网站 | 国产麻豆精品人妻无码A片 国产麻豆精品久久一二三 国产麻豆精品传媒AV国产在线 | 越南美女内射BBWXZ | 国产成人ae在线观看网站站 | 69SEX久久精品国产麻豆 | 亚洲阿v天堂在线2017 | 国产精品免费小视频 | 国产精品夜夜春夜夜爽久久小 | 亚洲日韩乱码人人爽人人澡人 | 你的欲梦裸身在线播放 | 不良网站进入窗口软件下载免费 | 鲁大师影院在线视频在线观看 | 理论片87福利理论电影 | 少妇无码吹潮久久精品AV网站 | 18国产精品白浆在线观看免费 | 天天澡夜夜澡人人澡 | 一本大道熟女人妻中文字幕在线 | 国产69精品久久久熟女 | 久久麻豆亚洲AV成人无码国产 | 光溜溜的美女直播软件 | 97色伦亚洲自偷 | 迅雷哥在线观看高清 | 大乳牛奶女在线观看 | 很很射影院 | 综合一区无套内射中文字幕 | 国产成A人片在线观看 | 日本人HD18HD18| 真实国产熟睡乱子伦对白无套 | 无码AV动漫精品一区二区免费 | 色偷偷在线视频 | 久久re视频这里精品一本到99 | 日本又黄又裸一级大黄裸片 | 白丝女仆被啪到深夜漫画 | 日本一卡二卡三卡四卡无卡免费播放 | 国产精品俺来也在线观看 | 为什么丈夫插我我却喜欢被打着插 | 天天狠狠色综合图片区 | 男人边吃奶边摸边做刺激情话 | 999www成人免费视频 |