List<String> A = new List<string>();
A.Add("1");
A.Add("2");
A.Add("3");
string joined = String.Join("\",\"", A);
So geting output string like 1","2","3
But we requred joined= "1","2","3"
How can this possible
thanks
string joined = "\"" + String.Join("\",\"", A) + "\"";
or maybe
string joined = String.Join(",", A.Select(s => "\"" + s + "\""));
IL :DThe String.Join method joins multiple items in a collection using the delimiter you specify.
So when you run this line of code:
string joined = String.Join("\",\"", A);
You've specified that the delimiter that separates your items is a comma in quotes:
","
That string only appears between items, not before the first one or after the last one.
You'll have to add a quote before the first and after the last manually.
",", the output would be like this: item1<separator>item2<separator>item3 (in your case separator is","). if you want heading and trailing double quote, you should add it manually.