Convert.ToBase64String Method (Byte, Int32, Int32, Base64FormattingOptions)
Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 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
An array of 8-bit unsigned integers.
An offset in inArray.
The number of elements of inArray to convert.
Return ValueType: System.String
The string representation in base 64 of length elements of inArray, starting at position offset.
The elements of the inArray parameter are taken as a numeric value and converted to a string representation in base 64.
The base-64 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 32-bit signed numbers. The offset parameter is zero-based.
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.rfc-editor.org/.
The following example demonstrates themethod. The input is divided into groups of three bytes (24 bits) each. Consequently, each group consists of four 6-bit numbers where each number ranges from decimal 0 to 63. In this example, there are 85 3-byte groups with one byte remaining. The first group consists of the hexadecimal values 00, 01, and 02, which yield four 6-bit values equal to decimal 0, 0, 4, and 2. Those four values correspond to the base-64 digits "A", "A", "E", and "C" at the beginning of the output.
If an integral number of 3-byte 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 base-64 digit "/" at the end of the output, and the next 2 bits are padded with zeros to yield decimal 48, which corresponds to the base-64 digit, "w". The last two 6-bit values are padding and correspond to the valueless padding character, "=".
Available since 2.0