String Format() - C# Tutorial
C# Course / Strings / String Format()

String Format()

BLUF: Mastering String Format() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Format()

C# is a powerful, modern language for enterprise solutions. Discover how String Format() enhances your development workflow in the guide below.

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

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience