LINQ Get comma separated words with single quote in C#
- First parameter itemCollection is input | Hello+we+are+here
- Second parameter separator is char | '+'
C# sample Code
public static string GetResults(string itemCollection,char separator)
{
string result = string.Empty;
if (String.IsNullOrEmpty(itemCollection)) return result;
else
{
result = string.Join(",", itemCollection.Split(separator).Select(x => string.Format("'{0}'", x.TrimStart().TrimEnd())).ToList());
}
return result;
}
0 Comments