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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -