CSharp examples for System:Hex
Converts to a string containing the buffer described in hex
using System.Text; using System.Collections.Generic; using System;//from w w w . j a v a 2 s . com public class Main{ /// <summary> /// Converts to a string containing the buffer described in hex /// </summary> public static string DescribeAsHex(byte[] buffer, string separator, int bytesPerLine) { StringBuilder sb = new StringBuilder(); int n = 0; foreach (byte b in buffer) { sb.AppendFormat("{0:X2}{1}", b, separator); if (++n % bytesPerLine == 0) sb.Append("\r\n"); } sb.Append("\r\n"); return sb.ToString(); } }