Writing content of an array to a textbox using foreach loop C# -
so, wanna know how write entire content of array textbox using foreach loop in c#. code looks this:
i generate series of random numbers stored in array:
int[] idata;
now want write stored data in array textbox using foreach loop this:
foreach (int myint in idata) { txtlisting.text = myint.tostring(); }
this write last generated number in array textbox, question how write of them tekstbox.
i know, how listbox , forloop. there way can done textbox , foreach loop?
try using appendtext
method instead:
foreach (int myint in idata) { txtlisting.appendtext(myint.tostring()); }
another option join elements string:
textlisting.text = string.join(string.empty, idata);
...or if want delimiter:
textlisting.text = string.join(", ", idata);
Comments
Post a Comment