The C# Format method is used to replace one or more format items in the specified string with the string representation of a specified object.
Signature
Example
public static string Format (String first, Object second)
public static string Format(IFormatProvider, String, Object)
public static string Format(IFormatProvider, String, Object, Object)
public static string Format(IFormatProvider, String, Object, Object, Object)
public static string Format(IFormatProvider, String, Object[])
public static string Format(String, Object, Object)
public static string Format(String, Object, Object, Object)
public static string Format(String, params Object[])
Parameters
first : it is a string type argument.
second: it is object type argument.
Return
It returns a formatted string.
C# String Format Method Example
Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = string.Format("{0:D}", DateTime.Now);
Console.WriteLine(s1);
}
}
Output:
Output
Saturday, December 17, 2016