How can I format a string like this:
string X = "'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}'",????
I remember I used to be able to put a comma at the end and specify the actual data to assign to {0},{1}, etc.
Any help?
Use string.Format method such as in:
string X = string.Format("'{0}','{1}','{2}'", foo, bar, baz);
An alternative is to use Join, if you have the values in a string array:
string x = "'" + String.Join("','", valueArray) + "'";
(Just wanted to be different from the 89724362 users who will show you how to use String.Format... ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With