Skip to content

Combined source. Use positional args and dictionary together #308

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

You must be logged in to vote

One option is to put positional arguments to the end:

var dict = new Dictionary<string, string> { { "PlayerName", "Joe" } };
const string format = "Player {PlayerName} gets {1} coins!";
var formatter = Smart.CreateDefaultSmartFormat();
var result = formatter.Format(format, dict, 1234);
// "Player Joe gets 1234 coins!"

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@ViacheslavRud
Comment options

@axunonb
Comment options

@axunonb
Comment options

@ViacheslavRud
Comment options

Answer selected by axunonb
Comment options

You must be logged in to vote
1 reply
@ViacheslavRud
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants