Concatenating string overwriting previous string C# -


i have program gets numbers user , stores them in list, takes each number , prints on textbox before printing average. however, have logic error adding 2 strings together. here code matters.

dataview.text = ""; if (comma) {     dataview.text = number.tostring(); } else  {     dataview.text += ", " + number.tostring(); } 

it checks if needs add comma adds according that. believe line isn't working, wrong.

dataview.text += ", " + number.tostring(); 

i think removes number there , puts number there now, not want, want show both.

your resetting string "" here

dataview.text = ""; 

so ofcourse whenever call

dataview.text += ", " + number.tostring(); 

it's going show

, 912837 (or whatever number) 

also, whenever find have comma, do

dataview.text = number.tostring(); 

which should

dataview.text += number.tostring(); 

if want append number instead of replace.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -