How to use C# string Format

How to use C# string Format

string Format method replace the argument Object into a text equivalent System.String.

Replace string Particular index for ex System.String.Format("Hi welcome Mr {0}","Sutahahr")

System.String.format(string format,Object arg0)

Parameters:

String format : The format String

The format String Syntax is like {indexNumber:formatCharacter}

Object arg0 : The object to be formatted.

Returns:

String : The formatted String

Examples :

Currency :

String.Format("{0:c}", 10) will return $10.00
The currency symbol ($) displayed depends on the global locale settings.

Date :

String.Format("Today's date is {0:D}", DateTime.Now)

You will get Today's date like : 01 January 2005

Time :

String.Format("The current time is {0:T}", DateTime.Now)

You will get Current Time Like : 10:10:12
--
J.SuThahar MCA

MicroSoft Technology Specialist

Microsoft Certified ProfessionalDeveloper

www.jsuthahar.tk

09943151415

0 Comments

Featured Post

AI Evolution Explained: GenAI vs LLMs vs AI Agents vs Agentic AI vs Intelligent AI

Artificial Intelligence (AI) is one of the most exciting technologies in our world today. But the terms that come with it like GenAI, LLMs, ...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts