 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert.ToBase64String() Method in C#
The Convert.ToBase64String() method in C# is used to convert the value of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits.
Syntax
Following is the syntax −
public static string ToBase64String (byte[] arr);
Above, arr is an array of 8-bit unsigned integers.
Example
Let us now see an example to implement the Convert.ToBase64String() method −
Using System;
public class Demo {
   public static void Main(){
      byte[] val1 = {5,10,15,20,25,30};
      string str = Convert.ToBase64String(val1);
      Console.WriteLine("Base 64 string: '{0}'", str);
      byte[] val2 = Convert.FromBase64String(str);
      Console.WriteLine("Converted byte value: {0}", BitConverter.ToString(val2));
   }
}
Output
This will produce the following output −
Base 64 string: 'BQoPFBke' Converted byte value: 05-0A-0F-14-19-1E
Advertisements
                    