CSharp · Console
// C# Extension Method
// Doc: https://csharp-extension.com/en/method/1002189/bytearray-tobase64chararray
// @nuget: Z.ExtensionMethods
using System;
public class Program
{
public static void Main()
{
byte[] byteArray = new byte[256];
char[] charArray = new char[352];
Console.WriteLine("A Byte array of arbitrary data.");
Console.WriteLine();
for (int x = 0; x < byteArray.Length; x++)
{
byteArray[x] = (byte)x;
Console.Write("{0:X2} ", byteArray[x]);
if (((x+1)%20) == 0)
Console.WriteLine();
}
Console.WriteLine();
// C# Extension Method: ByteArray - ToBase64CharArray
int charArrayLength = byteArray.ToBase64CharArray(0, byteArray.Length, charArray, 0);
Console.WriteLine();
Console.WriteLine("Convert the input Byte array to a Char array.");
Console.WriteLine();
for (int x = 0; x < charArray.Length; x++)
{
Console.Write("{0} ", charArray[x]);
if (((x+1)%20) == 0)
Console.WriteLine();
}
}
}