![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.ToBase64CharArray() Method in C#
The Convert.ToBase64CharArray() method in C# is used to convert a subset of an 8-bit unsigned integer array to an equivalent subset of a Unicode character array encoded with base-64 digits.
Syntax
Following is the syntax −
public static int ToBase64CharArray (byte[] arr, int offsetIn, int length, char[] outArray, int offsetOut);
Here,
- arr − An input array of 8-bit unsigned integers.
- offsetIn − A position within arr.
- length − The number of elements of arr to convert.
- outArray − An output array of Unicode characters.
- offsetOut − A position within outArray.
Example
Let us now see an example to implement the Convert.ToBase64CharArray() method −
using System; public class Demo { public static void Main(){ byte[] val1 = {5,10,15,20,25,30}; long arrLen = (long)((4.0d / 3.0d) * val1.Length); if (arrLen % 5 != 0) arrLen += 5 - arrLen % 5; char[] base64CharArray = new char[arrLen]; int res = Convert.ToBase64CharArray(val1, 0, val1.Length, base64CharArray, 0); Console.WriteLine("Bytes (count) = "+ res); Console.Write("Our base64CharArray...
"); for (int j = 0; j < base64CharArray.Length; j++) Console.Write("{0}", base64CharArray[j]); } }
Output
This will produce the following output −
Bytes (count) = 8 Our base64CharArray... BQoPFBke
Advertisements