Convert.ToBase64String Method (Byte[], Int32, Int32, Base64FormattingOptions)
Converts a subset of an array of 8bit unsigned integers to its equivalent string representation that is encoded with base64 digits. Parameters specify the subset as an offset in the input array, the number of elements in the array to convert, and whether to insert line breaks in the return value.
Assembly: mscorlib (in mscorlib.dll)
[<ComVisibleAttribute(false)>] static member ToBase64String : inArray:byte[] * offset:int * length:int * options:Base64FormattingOptions > string
Parameters
 inArray

Type:
System.Byte[]
An array of 8bit unsigned integers.
 offset

Type:
System.Int32
An offset in inArray.
 length

Type:
System.Int32
The number of elements of inArray to convert.
 options

Type:
System.Base64FormattingOptions
InsertLineBreaks to insert a line break every 76 characters, or None to not insert line breaks.
Return Value
Type: System.StringThe string representation in base 64 of length elements of inArray, starting at position offset.
Exception  Condition 

ArgumentNullException  inArray is null. 
ArgumentOutOfRangeException  offset or length is negative. or offset plus length is greater than the length of inArray. 
ArgumentException  options is not a valid Base64FormattingOptions value. 
The elements of the inArray parameter are taken as a numeric value and converted to a string representation in base 64.
The base64 digits in ascending order from zero are the uppercase characters "A" to "Z", the lowercase characters "a" to "z", the numerals "0" to "9", and the symbols "+" and "/". The valueless character "=" is used for trailing padding.
The offset and length parameters are 32bit signed numbers. The offset parameter is zerobased.
Important 

The ToBase64String method is designed to process a single byte array that contains all the data to be encoded. To encode data from a stream, use the System.Security.Cryptography.ToBase64Transform class. 
If the options parameter is set to InsertLineBreaks and the output of the conversion is longer than 76 characters, a line break is inserted every 76 characters. A line break is defined as a carriage return character (U+000D) followed by a line feed character (U+000A). For more information, see RFC 2045, "Multipurpose Internet Mail Extensions", at http://www.rfceditor.org/.
The following example demonstrates the ToBase64String method. The input is divided into groups of three bytes (24 bits) each. Consequently, each group consists of four 6bit numbers where each number ranges from decimal 0 to 63. In this example, there are 85 3byte groups with one byte remaining. The first group consists of the hexadecimal values 00, 01, and 02, which yield four 6bit values equal to decimal 0, 0, 4, and 2. Those four values correspond to the base64 digits "A", "A", "E", and "C" at the beginning of the output.
If an integral number of 3byte groups does not exist, the remaining bytes are effectively padded with zeros to form a complete group. In this example, the value of the last byte is hexadecimal FF. The first 6 bits are equal to decimal 63, which corresponds to the base64 digit "/" at the end of the output, and the next 2 bits are padded with zeros to yield decimal 48, which corresponds to the base64 digit, "w". The last two 6bit values are padding and correspond to the valueless padding character, "=".
Available since 2.0