C# Convert FromBase64String

Description

Convert FromBase64String converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array.

Syntax

Convert.FromBase64String has the following syntax.


public static byte[] FromBase64String(
  string s
)

Parameters

Convert.FromBase64String has the following parameters.

  • s - The string to convert.

Returns

Convert.FromBase64String method returns

Example


/*w w  w.ja v  a 2  s .c  o m*/
using System;
class Sample 
{
    public static void Main() 
    {
        byte[] inArray  = new byte[256];
        byte[] outArray = new byte[256];
        string s2;
        string s3;
        int x;
    
        for (x = 0; x < inArray.Length; x++){
            inArray[x] = (byte)x;
        }
        s2 = Convert.ToBase64String(inArray, 0, inArray.Length, Base64FormattingOptions.InsertLineBreaks);
        s3 = Convert.ToBase64String(inArray, Base64FormattingOptions.InsertLineBreaks);
        outArray = Convert.FromBase64String(s2);

   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version