How to use C# string Format

2
1



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

string 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

Exceptions:

System.ArgumentNullException : The format String is null.

System.FormatException : The format item in format is invalid.

The number indicating an argument to format is less than zero, or greater than or equal to

the number of specified objects to format.

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

Moreover, you should also visit our:

Website:
Blog:
Shop:
FbPage:
Twitter:
Google+ :
YouTube:
Email: help@theengineeringprojects.com
Skype: theenggprojects
Mobile / WhatsApp : +92-332-6062060

Thanks for Watching.

Nguồn:https://wijstaanvooronzegrondrechten.org/

Xem Thêm Bài Viết Khác:https://wijstaanvooronzegrondrechten.org/cong-nghe

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here