Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ("{0,1} ", num); mean?

Tags:

c#

New to C# and I am trying to understand a statement

foreach (int num in numQuery)
{
    Console.Write("{0,1} ", num);
}

I am confused about what is that {0, 1} doing there. If it is "{0}", then it is pretty clear, but what does {0, 1} mean?

like image 567
Anson Yao Avatar asked Jun 26 '26 22:06

Anson Yao


1 Answers

It looks like it is a custom numeric format string, but matter of fact Charles is right in his comment:

0 is the placeholder 1 is the size of the field so that you can display a columnar result. You can read about this on MSDN by looking at String.Format under the Controlling Spacing section)

like image 64
nvoigt Avatar answered Jun 28 '26 10:06

nvoigt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!