Created
April 15, 2013 14:48
-
-
Save smonn/5388651 to your computer and use it in GitHub Desktop.
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; | |
using System.Linq; | |
var bytes = new byte[] { /* ... */ }; | |
var hex = new string(bytes.SelectMany(x => x.ToString("x2").ToCharArray()).ToArray()); | |
var data = Enumerable.Range(0, hex.Length).Where(x => x % 2 == 0) | |
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) | |
.ToArray(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment