public string GetCommaSeparatedWithSingleQuotes(string[] pkgs)
{
StringBuilder pkgnames = new StringBuilder();
string finalpkgnames;
for(int i=0; i<pkgs.Length; i++)
{
// package name has got single/double quotes. It must be single string without quotes
if (pkgs[i].Trim().Contains("'") || pkgs[i].Trim().Contains("\""))
{
return null;
}
if (i == pkgs.Length - 1) // if last item. Dont put comma at the end
{
pkgnames.Append("'" + pkgs[i].Trim() + "'");
}
else //put comma because there are more items in the list
{
pkgnames.Append("'" + pkgs[i].Trim() + "', ");
}
}
finalpkgnames = pkgnames.ToString();
return finalpkgnames;
}