Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does {0} mean in String.Format?

E.g. in the following example:

string commandText = string.Format("Select * from {0}", filename);

How does the above work?

like image 424
StevieB Avatar asked Nov 19 '25 02:11

StevieB


1 Answers

{0} is a placeholder for the first object given; in this case that's filename, so it will insert whatever filename evaluates to in place of {0}. Similarly, of course you could use {1} and that would be replaced with the second parameter passed, etc.

like image 200
Alexander Corwin Avatar answered Nov 20 '25 16:11

Alexander Corwin



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!