Convert.ToBase64CharArray() Convert.FromBase64CharArray : Convert from string « Data Type « C# / CSharp Tutorial






using System;

class Sample 
{
    public static void Main() 
    {
        byte[] byteArray1 = new byte[256];
        byte[] byteArray2 = new byte[256];
        char[] charArray  = new char[352];
        int charArrayLength;
        for (int x = 0; x < byteArray1.Length; x++)
        {
            byteArray1[x] = (byte)x;
            Console.Write("{0:X2} ", byteArray1[x]);
        }
        charArrayLength = Convert.ToBase64CharArray(byteArray1, 0, byteArray1.Length, charArray, 0, Base64FormattingOptions.InsertLineBreaks);
        Console.Write(charArrayLength);
        
        Console.WriteLine(new String(charArray));
        
        byteArray2 = Convert.FromBase64CharArray(charArray, 0, charArrayLength);
    }
}








2.51.Convert from string
2.51.1.New and old way to parse an int
2.51.2.new-style (v2.0) try-parse pattern
2.51.3.Type Conversion Using System.Convert
2.51.4.Using TryParse() in Place of an Invalid Cast Exception
2.51.5.Data type parsing
2.51.6.Convert.ToBase64CharArray() Convert.FromBase64CharArray
2.51.7.Example of the BitConverter.GetBytes( uint ) method.