Convert List to Comma Separated String Using string.Join()
To convert the list into comma separated string we will use an inbuilt string.Join() method. So, suppose we are having the below mention list.
List<string> nameDataList = new List<string>()
{
"User 1",
"User 2",
"User 3",
"User 4"
};
In above list i have added user names in the user list. Now let's check code how we can convert the list of string into comma separated string using string.Join().string finalString=string.Join(", ", nameDataList);
Console.WriteLine(finalString);
Console.ReadLine();
In above code I have converted the list into string having comma value. Now lets run the code by putting a break point.