System.HexConvert.ToHex C# (CSharp) Method

ToHex() public static method

public static ToHex ( byte buffer, int offset, int count ) : string
buffer byte
offset int
count int
return string
		public static string ToHex(byte[] buffer, int offset, int count)
		{
			if (buffer == null) throw new ArgumentNullException("buffer");
			if (offset < 0) throw new ArgumentOutOfRangeException("offset");
			if (count < 0) throw new ArgumentOutOfRangeException("count");
			if (offset + count > buffer.Length) throw new ArgumentOutOfRangeException("count");

			if (count == 0) return string.Empty;

			var hexString = new StringBuilder(buffer.Length * 2);
			hexString.Append('0', hexString.Capacity);

			var end = offset + count;
			var hexStringIndex = 0;
			for (var index = offset; index < end; index++)
			{
				var value = buffer[index];
				hexString[hexStringIndex] = HexChar[(value >> 4) & 15u];
				hexString[hexStringIndex + 1] = HexChar[value & 15u];
				hexStringIndex += 2;
			}

			return hexString.ToString();
		}
		public static char[] ToHexBuffer(byte[] buffer)

Same methods

HexConvert::ToHex ( byte value, char hexBuffer, int offset ) : int
HexConvert::ToHex ( uint value, char hexBuffer, int offset ) : int
HexConvert::ToHex ( ulong value, char hexBuffer, int offset ) : int
HexConvert::ToHex ( ushort value, char hexBuffer, int offset ) : int
HexConvert::ToHex ( byte buffer ) : string