Alex Rivera | Logout

What do the curly braces mean in C# strings?

Asked 2012-03-19T11:30:07.653
12
while (rdr.Read())
{
    Console.WriteLine("Product: {0,-35} Total: {1,2}", rdr["ProductName"], rdr["Total"]);
}

What does {0,-35} mean in this code?

Edit
Report

1 Answer

2

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.

answered 2012-03-19T11:33:49.077

Your Answer