Song Lee

Song Lee

  • NA
  • 47
  • 37.3k

Adding Double, String value on listbox.

Feb 5 2015 8:41 PM
Hello,
I'm trying to make listbox show a few string and double values when button is pressed.
However, I'm  getting errors: Cannot implicitly convert type 'string' to 'double' When ever I put double agestr = ageText.Text;
How can I make it so agestr and teethstr text box only accepts double values? 
 
private void addButton_Click(object sender, EventArgs e)
string namestr = nameText.Text;
string agestr = ageText.Text;    //This needs to be double, not  string
string genderstr = genderList.Text;
string teethstr = teethText.Text;  //This needs to be double, not string
string tailstr = tailText.Text; 
 
string row = String.Format("{0} {1} {2} Has {3} teeth. tail is {4} cm long", namestr, agestr, genderstr, teethstr, tailstr);
listBox.Items.Add(row);
 

Answers (3)