c# 4.0 - How to call an item from a list of items in c# -
i got list this, method isn't working, appreciated.
//my list of values list<string> values = new list { "$100","$300","$500"};
in button1_click method
int = 2; object o = values[i];//i want have value 2 this.button1.text = convert.tostring(i); //i want button text out value values[i].
you're converting wrong item.
this.button1.text = convert.tostring(i); //<---- should o
change to:
this.button1.text = convert.tostring(o);
but shouldn't converting string
object
, string
.
could use:
this.button1.text = values[i];