The C# Format function is utilized for substituting one or more format placeholders within the given string with the string representation of a specific 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