Format Byte Array - CSharp System

CSharp examples for System:Byte Array

Description

Format Byte Array

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*  w  ww.  ja  v  a  2 s .co  m*/

public class Main{
    public static string FormatByteArray(byte[] b)
      { 
         var sb1 = new StringBuilder();
         var i = 0;
         for (i = 0; i < b.Length; i++)
         {
            if (i != 0 && i % 16 == 0)
               sb1.Append("\n");
            sb1.Append(System.String.Format("{0:X2} ", b[i]));
         }
         return sb1.ToString();
      }
}

Related Tutorials