Parse Byte Hex String - CSharp System

CSharp examples for System:Byte

Description

Parse Byte Hex String

Demo Code


using System.Text;
using System.Security.Cryptography;
using System.Globalization;
using System;/*from ww  w  .  j a  va2s .c  o  m*/

public class Main{

        private static string ParseByte2HexStr(byte[] input)
        {
            if (input == null)
                return null;

            StringBuilder output = new StringBuilder(input.Length * 2);

            for (int i = 0; i < input.Length; i++)
            {
                int current = input[i] & 0xff;
                if (current < 16)
                    output.Append("0");
                output.Append(current.ToString("x"));
            }

            return output.ToString().ToUpper();
        }
}

Related Tutorials