Get Hex String from byte array - CSharp System

CSharp examples for System:Byte Array

Description

Get Hex String from byte array

Demo Code


using System.Text;
using System.Collections.Generic;
using System.Collections;
using System;//from  w  w w  .jav a2  s .c o m

public class Main{
        public static string GetHexString(this byte[] data, int start = 0, int length = -1)
        {
            if (length < 0)
                length = data.Length;

            string str = "";
            for (int i = start; i < start + length; i++)
                str += data[i].ToString("X2") + " ";

            return str.Trim();
        }
}

Related Tutorials