CSharp examples for System:Byte
Parse Hex String Byte
using System.Text; using System.Security.Cryptography; using System.Globalization; using System;/*from ww w .j a va2 s . c om*/ public class Main{ private static byte[] ParseHexStr2Byte(String hexStr) { if (hexStr.Length < 1) return null; int length = hexStr.Length / 2; byte[] result = new byte[length]; for (int i = 0; i < length; i++) { int high = int.Parse(hexStr.Substring(i * 2, 1), NumberStyles.AllowHexSpecifier); int low = int.Parse(hexStr.Substring(i * 2 + 1, 1), NumberStyles.AllowHexSpecifier); result[i] = (byte)(high * 16 + low); } return result; } }