C# String Format(String, Object, Object, Object)
Description
String Format(String, Object, Object, Object)
replaces
the format items in a specified string with the string representation of
three specified objects.
Syntax
String.Format(String, Object, Object, Object)
has the following syntax.
public static string Format(
string format,// w w w .j ava 2 s.c om
Object arg0,
Object arg1,
Object arg2
)
Parameters
String.Format(String, Object, Object, Object)
has the following parameters.
format
- A composite format string.arg0
- The first object to format.arg1
- The second object to format.arg2
- The third object to format.
Returns
String.Format(String, Object, Object, Object)
method returns A copy of format in which the format items have been replaced by the string
representations of arg0, arg1, and arg2.
Example
The following code shows how to use
String.Format(String, Object, Object, Object)
method.
// w w w. j a v a 2s . c o m
using System;
public class MainClass
{
public static void Main(String[] argv){
double temperature = 68.3;
string result = String.Format("At {0:t} on {0:D}, the temperature was {1:F1} degrees Fahrenheit({1:F1}).",
DateTime.Now, temperature, temperature);
Console.WriteLine(result);
}
}
The code above generates the following result.