Are these formatting conventions consistent?

String.Format("{0:d}", item.ReleaseDate)

In the above code, 'd' is used to hold the seat for item.ReleaseDate

While

String.Format("{0:c}", item.Price)

'c' is used for placeholder for item.Price.

Are there any restrictions that should only be used d for DateTimeand c, for price?

Sorry I'm technical in technical agreements. Please correct me in the conventions.

+3
source share
1 answer

d for decimal, c for currency in your example. The value can be changed depending on the variable that will be used instead of the placeholder.

http://sharpertutorials.com/string-formatting/

. .

+7

Source: https://habr.com/ru/post/1789225/


All Articles