If i would like to take an interger value and display it on a label control, within a string, how do I accomplish this?
Ex.
Read an input from textbox1.Text and have a label display "The input from the textbox is: " The actual value of TextBox1.Text should go after the colon. How is this accomplished in C#.NEt ?
Thank You
Display Variable Values
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
james thomas8 pointsPosted Apr 30, 2007, 12:27 PM EDT
lblsomeLabel.Text = textbox1.Text;
would work.
however if you wanted the value of textbox1.Text to be of type int you would have to call the conversion of the text property
// declare variable
int value;
// parse the .text property to type int and set variable equal to the resultant int value
value = int.parse(textbox1.Text);
// get lblsomeLabel to display the int variable by calling the tostring method.
lblsomeLabel.Text = "The input from the textbox is: " + value.tostring()
Hope this helps im still learning myself
Jay
Shaun5 pointsPosted Apr 30, 2007, 12:47 PM EDT
james thomas8 pointsPosted Apr 30, 2007, 12:50 PM EDT
Jay