I work on C#. I have an array. To separate the array items I need to use comma. I did it but I think it's not efficient. How to do that, without an if condition? Please don't use replace method. My syntax is below.
string container = "";
string[] s = "Hellow world how are you".Split(' ');
foreach (string item in s)
{
if (container == "")
{
container += item;
}
else
{
container += "," + item;
}
}
I must need to continue the loop. I just want below type solution.
string container = "";
string[] s = "Hellow world how are you".Split(' ');
foreach (string item in s)
{
container += "," + item;
}
Thanks in advance. If have any queries please ask.