using System.Text;
namespace My.Helpers
{
public static class ByteExtensions
{
public static string ToHexString(this byte[] array)
{
// Create a new StringBuilder to collect the bytes and create a string.
var sBuilder = new StringBuilder();
// Convert to a hex string.
for (int i = 0; i < array.Length; i++)
sBuilder.Append(array[i].ToString("x2"));
// Return the hex string.
return sBuilder.ToString();
}
}
}
Thursday, 30 June 2011
C# - Byte Array Extensions - ToHexString
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment