How to convert a list of strings IList<string> or IEnumerable<string> to a comma-separated string in C#?
Hello everyone! I'm new to C# and came across this task: I have a list of strings (e.g., usernames), and I need to output them separated by commas into a single string for a log or report. I'm using the `IList` or `IEnumerable` interface, but I can't figure out how to do it elegantly.\n\nCurrently I'm doing it like this:\n\n```csharp\nIList names = new List { "Anna", "Boris", "Victor" };\nstring result = "";\nfor (int i = 0; i < names.Count; i++)\n{\n result += names[i];\n if (i < names.Count - 1)\n result += ", ";\n}\nConsole.WriteLine(result);\n```\n\nThis works, but the code looks bulky and ugly. Especially if the list is empty — then I get an empty string, but I've already handled the extra commas. Is there a more elegant way? Maybe some kind of