欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#中Byte轉(zhuǎn)換相關(guān)的函數(shù)

 更新時(shí)間:2016年05月03日 15:11:33   作者:伖先生  
這篇文章主要介紹了C#中Byte轉(zhuǎn)換相關(guān)的函數(shù)介紹,非常具有參考借鑒價(jià)值,特此分享到腳本之家平臺(tái)供大家學(xué)習(xí)

 1、將一個(gè)對(duì)象轉(zhuǎn)換為byte對(duì)象

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、將一個(gè)十六進(jìn)制字符串轉(zhuǎn)換為byte對(duì)象,字符串以0x開頭

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

3、將單個(gè)字符轉(zhuǎn)換為byte對(duì)象

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

4、將一個(gè)字符串轉(zhuǎn)換為byte數(shù)組

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

以上內(nèi)容是小編給大家介紹的C#中Byte轉(zhuǎn)換相關(guān)的函數(shù),希望對(duì)大家有所幫助!

相關(guān)文章

最新評(píng)論