Mono Class Library: System.String Overview | Members

System.String.Format Method

Replaces the format specification in a specified string with the culture-specific textual equivalent of the value of a corresponding object instance in a specified array.

public static string Format (IFormatProvider provider, string format, params object[] args)

Parameters

provider
A IFormatProvider interface that supplies an object that provides culture-specific formatting information. Can be a null reference.
format
A string containing zero or more format specifications.
args
A object array to be formatted.

Returns

A string containing a copy of format in which the format specifications have been replaced by the string equivalent of the corresponding instances of object in args .

Exceptions

TypeReason
ArgumentNullExceptionformat or args is a null reference.
FormatException

format is invalid.

-or-

The number indicating an argument to be formatted (N) is less than zero, or greater than or equal to the length of the args array.

Remarks

If an object referenced in the format string is a null reference, an empty string is used in its place.

The format parameter string is embedded with zero or more format specifications of the form, {N [, M ][: formatString ]}, where N is a zero-based integer indicating the argument to be formatted, M is an optional integer indicating the width of the region to contain the formatted value, and formatString is an optional string of formatting codes.

Note: For more information on the format specification see the string class overview.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0