c# - Convert List into Comma-Separated String -



c# - Convert List into Comma-Separated String -

my code below:

public void readlistitem() { list<uint> lst = new list<uint>() { 1, 2, 3, 4, 5 }; string str = string.empty; foreach (var item in lst) str = str + item + ","; str = str.remove(str.length - 1); console.writeline(str); }

output: 1,2,3,4,5

what simple way convert list<uint> comma-separated string?

enjoy!

console.writeline(string.join(",", new list<uint> { 1, 2, 3, 4, 5 }));

string.join take list sec parameter , bring together of elements using string passed first parameter 1 single string.

c# .net

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -