I have an array like this:
object[] args
and need to insert those args in a string, for example:
Help from more experienced C# users is needed! Thanks
The ParamArray Attribute and the Method Call
Note that the ParamArray attribute is applied to the args parameter. (See http://msdn.microsoft.com/en-us/library/system.paramarrayattribute.aspx for documentation on the ParamArrayAttribute class.) This means that the arguments can be specified to the method in either of two forms: either as a comma-delimited list of values, or as an array. So both
str = String.Format("Her name is {0} and she's {1} years old", args);
and
str = String.Format("Her name is {0} and she's {1} years old", args[0], args[1]);
as well as
string name;
int age;
str = String.Format("Her name is {0} and she's {1} years old", name, age);
all compile and execute successfully.