How to use C# string Format

preview_player
Показать описание
string Format method replace the argument Object into a text equivalent System.String.

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:

Skype: theenggprojects
Mobile / WhatsApp : +92-332-6062060

Thanks for Watching.
Рекомендации по теме
Комментарии
Автор

You are the man of the season. I love the video and will always be your subscriber.

adewaleayeseteminkan
Автор

I want more about Format() methods parameters.

salempurabhijeet
visit shbcf.ru