c# - different ways String Join -


can recommend better way joining string together.

i've got 2 lists i'm joining this:

textbox1.text = string.join(environment.newline, changeswithvalues); 

however data out has got bit in should there.

my on code bit looks this:

private void convertotext(dictionary<string, int> dictionarylist)     {         list<keyvaluepair<string, int>> changeswithvalues = dictionarylist.tolist();          display(changeswithvalues);     }      private void display(list<keyvaluepair<string, int>> changeswithvalues)     {         textbox1.text = string.join(environment.newline, changeswithvalues);     }      private void show_click(object sender, system.eventargs e)     {         convertotext(_dictionary);     } 

you need combine key , value of keyvaluepair format want, e.g.

textbox1.text = string.join(environment.newline, changeswithvalues.select(kvp => string.format("{0} {1}", kvp.key, kvp.value))); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -