while (rdr.Read())
{
Console.WriteLine(\"Product: {0,-35} Total: {1,2}\", rdr[\"ProductName\"], rdr[\"Total\"]);
}
What does {0,-35} mean in this c
Those brackets are placeholders in strings for values.
So, rdr["ProductName"]
will be formatted into the first brackets of the string. And rdr["Total"]
will be formatted in the second brackets of the string.
Provided this:
rdr["ProductName"] = "My Product";
rdr["Total"] = 2.98;
Then you will output to the console:
Product: My Product Total: 2.98
After question update:
The {0,-35}
part if for alignment purpose. More information on formatting and alignment on C#'s official documentation.