RE: Formatting Strings in .NET

You are viewing a single comment's thread from:

Formatting Strings in .NET

in utopian-io •  7 years ago 

Good work! A link to all the string format specifiers might help for other people who read this post.

Also, you can use string interpolation since C# 6.0. It has much clearer syntax, e.g.:

var stockNumber = 3;
var unitPrice = 12.34;
Console.WriteLine("stockNumber: {stockNumber:D4}, unitPrice: {unitPrice:C}")
// outputs: stockNumber: 0003, unitPrice: $12.34
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!