A Function to Concat String Array Values by Specified Delimiter

Let ‘s Say I have Following Array:

string[] st = new string[5];
st[0] = "Animation";
st[1] = "Action";
st[2] = "Romance";
st[3] = "Drame";
st[4] = "Comedy";

Now I want to Merge all of it with ‘,’ Delimiter Like Below:

Output :   Animation,Action,Romance,Drame,Comedy

Here is the Function For the Above

public string GetAllStringsFromArrary(string[] strArray,string strDelimeter)
string strFinal = string.Empty;

for (int i = 0; i < strArray.Length ; i++)
strFinal += strArray[i];

if (i != strArray.Length - 1)
strFinal += strDelimeter;
return strFinal;


We will Call it Like This:

string str = GetAllStringsFromArrary( st,",");


a dev, an amateur photographer and a father


Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: