c# - StringBuilder AppendFormat IEnumarble -


i have string builder , list of object ,

int[] values = new int[] {1,2}; stringbuilder builder = new stringbuilder(); builder.appendformat("{0}, {1}", values ); 

i see intellisense error

none existing arguments in format string

why seeing error ,and how should use list parameters inside appendformat

the overload of appendformat using (or compiler decided use) has following signature:

public stringbuilder appendformat(string format, object arg0) 

it expecting single argument , therefore format contains 2 arguments ("{0}, {1}") invalid.

your intention pass array multiple arguments, overload need use following:

public stringbuilder appendformat(string format, params object[] args) 

note second argument object[], not int[]. make code use overload, need convert int array object array this:

builder.appendformat("{0}, {1}", values.cast<object>().toarray()); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -