KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to be able to type something like: Console.WriteLine("You have {0:life/lives} left.", player.Lives); instead of Console.WriteLine("You have {0} {1} left.", player.Lives, player.Lives == 1 ? "life" : "lives"); so that for player.Lives == 1 the output would be: You have 1 life left. for player.Lives != 1 : You have 5 lives left. or Console.WriteLine("{0:day[s]} till doomsday.", tillDoomsdayTimeSpan); Some systems have that built-in. How close can I get to that notation in C#? EDIT: Yes, I am specifically looking for syntactic sugar, and not a method to determine what singular/plural forms are.
Tags (comma-separated)
Save Edits
Cancel