pass an array with unknown objects into string.Format in c# -
i output objects in array of strings length variable.
example 1 : string id = a; string [] values = new string [] {"12","23"}; string output = string.format("{0}, {1}, id, values); //output should "a,12,23" example 2 : string id = a; string [] values = new string [] {"12","23","45","67","89"}; string output = string.format("{0}, {1}, id, values); //output should "a,12,23,45,67,89"
is there way cover number of values or need convert values string , output it?
you string.join(string, string[])
string.join(",", values)
it add separator char , output in way want it
an overview of methods use here:
https://msdn.microsoft.com/en-us/library/system.string.join%28v=vs.110%29.aspx
Comments
Post a Comment