Skip to content

How to use arguments to Smart.Format #352

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

You must be logged in to vote
var player = new { Name = "Joe", SteamID = 1234, IP = "127.0.0.1" };
var now =  DateTime.Now.ToString(CultureInfo.InvariantCulture);
var arg = new { player, now };
var format = "[{now}] [-] {player.Name} ({player.SteamID})) [{player.IP}]";
var result = Smart.Format(format, arg);
// "[09/02/2023 08:58:07] [-] Joe (1234)) [127.0.0.1]"
//
// or
//
format = "[{0}] [-] {1.Name} ({1.SteamID})) [{1.IP}]";
result = Smart.Format(format, now, player);
// [09/02/2023 09:02:01] [-] Joe (1234)) [127.0.0.1]

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@Bluscream
Comment options

@axunonb
Comment options

@Bluscream
Comment options

Comment options

You must be logged in to vote
2 replies
@Bluscream
Comment options

@axunonb
Comment options

Answer selected by axunonb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #351 on September 01, 2023 19:36.