星空网 > 软件开发 > ASP.net

C#中Byte转换相关的函数

1、将一个对象转换为byte对象

public static byte GetByte(object o){byte retInt = 0;if (o != null){byte tmp;if (byte.TryParse(o.ToString().Trim(), out tmp)){retInt = tmp;}}return retInt;}

 

2、将一个十六进制字符串转换为byte对象,字符串以0x开头

public static byte GetByteFormHex(string hexValue){try{return Convert.ToByte(hexValue, 16);}catch {return 0;}}

 

3、将单个字符转换为byte对象

public static byte GetByteFormSingleString(string value){return GetByteFormChar(Convert.ToChar(value));}

 

4、将一个字符串转换为byte数组

public static byte[] GetBytes(string values){return System.Text.Encoding.Default.GetBytes(values);}

 




原标题:C#中Byte转换相关的函数

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

美国的海运港口:https://www.goluckyvip.com/tag/90018.html
买家拒付影响:https://www.goluckyvip.com/tag/9002.html
美国到海运:https://www.goluckyvip.com/tag/90020.html
美国海运港口:https://www.goluckyvip.com/tag/90021.html
海运国际海运服务:https://www.goluckyvip.com/tag/90022.html
国际海运服务:https://www.goluckyvip.com/tag/90023.html
活动回顾 | 千亚麦佳携手MoonSees呈现精彩亚马逊运营管理课程:https://www.kjdsnews.com/a/1836386.html
生日景点免费 上海景点生日免费景点:https://www.vstour.cn/a/363173.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流