C# String.Format Function && Syntactic Sugar

The Format Item Syntax

  • { index[,alignment][ :formatString] }
  • Escape Brace: To output a { you use {{ and to output a } you use }}.
  • Reference: MSDN Help
string t = "1, 2, 3";
string v = String.Format(" foo {{{0}}}", t);

Syntactic sugar

string t= "1, 2, 3";
string v = $"" foo {{{t}}}"";
posted @ 2020-05-28 09:11  Lee.Yan  阅读(132)  评论(0编辑  收藏  举报