Convert.ToBase64String Method (Byte[], Int32, Int32)

Converts a subset of an array of 8-bit unsigned integers to its equivalent String representation encoded with base 64 digits. Parameters specify the subset as an offset in the input array, and the number of elements in the array to convert.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static string ToBase64String (
	byte[] inArray,
	int offset,
	int length
public static String ToBase64String (
	byte[] inArray, 
	int offset, 
	int length
public static function ToBase64String (
	inArray : byte[], 
	offset : int, 
	length : int
) : String
Not applicable.



An array of 8-bit unsigned integers.


An offset in inArray.


The number of elements of inArray to convert.

Return Value

The String representation in base 64 of length elements of inArray starting at position offset.

Exception typeCondition


inArray is a null reference (Nothing in Visual Basic).


offset or length is negative.


offset plus length is greater than the length of inArray.

The elements of inArray 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.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions