Created
October 27, 2017 16:16
-
-
Save rquackenbush/72d7294fc8b6f71b3ec949129a239cd1 to your computer and use it in GitHub Desktop.
Hex formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text; | |
namespace CaptiveAire.Scada.Module.Base.Extensions | |
{ | |
public static class ArrayExtensions | |
{ | |
public static string ToHex(this byte[] bytes, bool upperCase = false) | |
{ | |
StringBuilder result = new StringBuilder(bytes.Length * 2); | |
foreach (byte b in bytes) | |
{ | |
result.Append(b.ToString(upperCase ? "X2" : "x2")); | |
} | |
return result.ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment