![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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