i have array with n-elements;
var arr = ["answer1", "answer2", "answer3"];
I need such result:
{"text":"answer1"},{"text":"answer2"},{"text":"answer3"}
Tried sothing like this:
string.Join(",", arr);
But how add {"text":" "} to each element?
You can use LINQ to select from the array with the additional text:
var arrayWithText = arr.Select(a => "{\"text\":\"" + a + "\"}");
var result = string.Join(",", arrayWithText);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With