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
Loading
james thomasPosted Apr 30, 2007, 4:50 PM
Jay
ShaunPosted Apr 30, 2007, 4:47 PM
james thomasPosted Apr 30, 2007, 4:27 PM
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