Convert byte array To Hex String - CSharp System

CSharp examples for System:Byte Array

Description

Convert byte array To Hex String

Demo Code


using System.Text;
using System.IO;// ww  w.  jav a 2s . co  m
using System.Globalization;
using System;

public class Main{
        public static string ToHex(this byte[] array)
        {
            StringBuilder stringBuilder = new StringBuilder(array.Length * 2);
            for (int index = 0; index < array.Length; ++index)
                stringBuilder.Append(array[index].ToString("x2"));
            return stringBuilder.ToString();
        }
}

Related Tutorials