Monday, March 26, 2012

String/Listbox question

I'm trying to get a handle on C#, but it's frustrating me - in vb.net, I can say:

Dim lbText as string
lbText=Listbox1.SelectedItem.Text

but in C#, I try:
string lbText = listBox1.SelectedItem.ToString;

and I get an error:
Cannot convert method group 'ToString' to non-delegate type 'String'

I don't get it - how can I convert the selected item in the listbox (or dropdownlist) to a string?

I guess something like this:

string mySelectedText = ListBox1.SelectedItem.Text;

0 comments:

Post a Comment