asp.net.ph

String.Format Method ( String, Object, Object, Object )

System Namespace   String Class


Replaces the format specification in a specified String with the textual equivalent of the value of three specified Object instances.

[ VB ]
<Serializable>
Overloads Public Shared Function Format ( _
   ByVal format As String, _
   ByVal arg0 As Object, _
   ByVal arg1 As Object, _
   ByVal arg2 As Object _
) As String

[ C# ]
[ Serializable ]
public static string Format (
   string format,
   object arg0,
   object arg1,
   object arg2
);

[ C++ ]
[ Serializable ]
public: static String* Format (
   String* format,
   Object* arg0,
   Object* arg1,
   Object* arg2
);

[ JScript ]
public Serializable
static function Format (
   format : String,
   arg0 : Object,
   arg1 : Object,
   arg2 : Object
) : String;

Parameters

format
A String containing zero or more format specifications.
arg0
The first Object to be formatted.
arg1
The second Object to be formatted.
arg2
The third Object to be formatted.

Return Value

A copy of format in which the first, second, and third format specifications have been replaced by the String equivalent of the arg0, arg1, and arg2.

Exceptions


Exception Type Condition
ArgumentNullException format is a null reference ( Nothing in Visual Basic ).
FormatException format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or larger than or equal to the number of provided objects to be formatted.


Remarks

The format parameter 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, padded with spaces. If the sign of M is negative, the formatted value is left-justified in the region; if the sign of M is positive, the value is right-justified.
  • formatString is an optional string of formatting codes.

If argN implements IFormattable, then argN.Format ( formatString, null ) provides formatting; otherwise argN.ToString ( ) provides formatting. If argN is null, then an empty string is used in its place.If formatString is omitted, the ToString ( ) method of the argument specified by N provides formatting.

If the value of format is, "Thank you for your purchase of {0:####} copies of Microsoft® .NET ( Core Reference ).", and arg0 is an Int16 with the value 123, then the return value will be:

"Thank you for your purchase of 123 copies of Microsoft® .NET ( Core Reference )."

If the value of format is, "Brad's dog has {0,-8:G} fleas.", arg0 is an Int16 with the value 42, ( and in this example, underscores represent padding spaces ) then the return value will be:

"Brad's dog has 42______ fleas."

See Also

String Members   String.Format Overload List   Object   IFormattable Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph