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
Post a Comment