Skip to content

Instantly share code, notes, and snippets.

@smonn
Created April 15, 2013 14:48
Show Gist options
  • Save smonn/5388651 to your computer and use it in GitHub Desktop.
Save smonn/5388651 to your computer and use it in GitHub Desktop.
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