Skip to content

Format a list with dedicated wrapping characters #321

Answered by axunonb
iliashkolyar asked this question in Q&A
Discussion options

You must be logged in to vote

The members of the list are prepended with a * and appended with a *. The separator is ,.
The empty list should give an empty result.
So you could e.g. go for this:

var result = Smart.Format("{0.Count:choose(0):|{0:list:*{}*|, }}", input);
//
// for input = new List<string> { "one", "two" };
// output: "*one*, *two*"
//
// for input = new List<string>();
// output: ""

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by iliashkolyar
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants