a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 編程 > C# > 正文

C#中string與byte[]的轉換幫助類-.NET教程,C#語言

2024-09-07 17:05:19
字體:
來源:轉載
供稿:網友
 
主要實現了以下的函數 


代碼中出現的sidle是我的網名。 

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

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

hex與hexbin的轉換#region hex與hexbin的轉換 
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); 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 国产一级毛片电影 | 国产精品片一区二区三区 | 三级欧美在线观看 | 国产四虎 | 波多野结衣一二三四区 | 色噜噜狠狠色综合中国 | 欧美日韩国产综合视频 | 国产精品美女www爽爽爽动态图 | 四虎av在线| 国产欧美精品一区二区色综合朱莉 | 久久艹视频 | 波多野结衣 一区二区 | 欧美日韩综合视频 | 色噜噜在线观看 | 久久爱9191 | 久久久久久久香蕉 | 狠狠操操| 欧美在线一区二区 | 国产成人在线视频网站 | 国产精品永久免费 | 欧美在线一区二区三区 | 色综合中文 | 成人国产在线 | 日韩有码一区 | 国产免费一区二区 | 一级特黄aaa大片在线观看 | 中文字幕亚洲在线观看 | 国产精品99视频 | 亚洲国产高清视频 | 久久九九 | 欧洲成人午夜免费大片 | 一区二区影院 | 六月丁香av | 超碰在 | 羞羞视频免费在线观看 | 国产精品久久久久久福利一牛影视 | 国产精品成人3p一区二区三区 | 国产一区二区免费视频 | av网站观看 | 亚洲精品一区在线观看 | 欧美日韩不卡在线 |