字节数组(byte[])与16进制字符串转换

  /// <summary>
/// 转换扩展类
/// </summary>
public static class ConvertExtend
{
/// <summary>
/// 将byte[]转换为16进制字符串
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static string ToString16(this byte[] bytes)
{
return bytes.ToList().ToString16();
} /// <summary>
/// 将List<byte>转换为16进制字符串
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static string ToString16(this List<byte> bytes)
{
return string.Join(" ", bytes.ConvertAll(b => Convert.ToString(b, )));
} /// <summary>
/// 将16进制字符串转换为byte[]
/// </summary>
/// <param name="str16"></param>
/// <returns></returns>
public static byte[] ToByte(this string str16)
{
return str16.Split(' ').ToList().ConvertAll(s => Convert.ToByte(s, )).ToArray();
}
}

ConvertExtend

上一篇:linux 磁盘 扩展分区


下一篇:#WEB安全基础 : HTML/CSS | 0x7HTML5和W3C验证