Gets a hexa string from the byte array. - CSharp System

CSharp examples for System:Byte Array

Description

Gets a hexa string from the byte array.

Demo Code


using System.Text;
using System.Security.Cryptography;
using System.Linq;
using System.Collections.Generic;
using System;//from  w  w  w  .j a v  a 2 s .com

public class Main{
        #endregion

      /// <summary>
      /// Gets a hexa string from the byte array.
      /// </summary>
      /// <param name="data">Array to get a hexa string from</param>
      /// <returns>Hexa string from the byte array</returns>
      public static string GetHexaString(this byte[] data)
      {
         StringBuilder sb = new StringBuilder(data.Length * 2);

         for (int i = 0; i < data.Length; i++)
         {
            sb.Append(data[i].ToString("x2").ToUpper());
         }

         return sb.ToString();
      }
}

Related Tutorials