Convert string to Base 64 byte array in CSharp

Description

The following code shows how to convert string to Base 64 byte array.

Example


  //w ww .ja  v  a 2  s  .c om
  
  
   

using System;
using System.Data;
using System.Text.RegularExpressions;
using System.Text;
class Class1{
        static void Main(string[] args){
            foreach (byte b in Base64DecodeString("java2s.com")){
                Console.WriteLine(b);
            }
         }
    public static byte[] Base64DecodeString(string inputStr) 
    {
      byte[] encodedByteArray = Convert.FromBase64CharArray(inputStr.ToCharArray(), 0, inputStr.Length);
      return (encodedByteArray);
    }   
}




















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var