Bytes To Comma Separated List
/*
* Copyright (c) United Binary LLC. All rights reserved.
*
* This code is licensed under the MIT License
*
* SEE: http://harnessit.codeplex.com/license
*
*/
#region using ...
using System;
using System.Text;
#endregion
namespace UnitedBinary.Core.Utility.Text
{
/// <include file='Text.xml' path='/Docs/Format/Class/*'/>
public sealed class Format
{
private Format() {}
/// <include file='Text.xml' path='/Docs/Format/BytesToCommaSeparatedList/*'/>
public static string BytesToCommaSeparatedList(byte[] source)
{
StringBuilder sb = new StringBuilder();
for (int i=0; i < source.Length; i++)
{
sb.AppendFormat("{0}0x{1:X2}", (i == 0 ? "" : ", "), source[i]);
}
string list = sb.ToString();
return list;
}
}
}
Related examples in the same category