c# - Concatenate dictionary keys separated by comma's -


i'm looking better way concatenate dictionary keys, i'm doing :

dictionary<int, string> mylist = new dictionary<int, string>();  mylist.add(1, "value"); mylist.add(2, "value"); mylist.add(3, "value"); mylist.add(4, "value");  string choices = "";  foreach (int key in mylist.keys) {     choices += key + " "; }  choices = "(" + choices.trim().replace(" ", ",") + ")"; // (1,2,3,4) 

i'm sure there better way, linq maybe ?

string.format("({0})", string.join(",", mylist.keys)); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -