What do the curly braces mean in C# strings?

后端 未结 5 1795
情书的邮戳
情书的邮戳 2021-02-14 22:40
while (rdr.Read())
{
    Console.WriteLine(\"Product: {0,-35} Total: {1,2}\", rdr[\"ProductName\"], rdr[\"Total\"]);
}

What does {0,-35} mean in this c

5条回答
  •  囚心锁ツ
    2021-02-14 23:23

    Those {} brackets are for string formatting purpose. example, your case rdr["ProductName"] have given a format specifier {0,-35} ... which will be left aligned with space padded to the right.

提交回复
热议问题