Skip to content

Instantly share code, notes, and snippets.

@mgravell
Last active October 29, 2020 11:11
Show Gist options
  • Save mgravell/1177e9e07d310ca0eedcb0af64e680c3 to your computer and use it in GitHub Desktop.
Save mgravell/1177e9e07d310ca0eedcb0af64e680c3 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
static class P
{
static void Main()
{
var bytes = new List<byte>();
bytes.AddRange(new byte[] { 0, 1, 2, 3 });
bytes.AddRange(new byte[] { 4, 5 });
bytes.AddRange(new byte[] { 6, 7, 8 });
var arr = bytes.ToArray();
Console.WriteLine(BitConverter.ToString(arr));
// ^^ 00-01-02-03-04-05-06-07-08
var b64 = Convert.ToBase64String(arr);
Console.WriteLine(b64);
// ^^ AAECAwQFBgcI
var backAgain = Convert.FromBase64String(b64);
Console.WriteLine(BitConverter.ToString(backAgain));
// ^^ 00-01-02-03-04-05-06-07-08
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment