31. Suppose an application’s GUI has two TextBox controls named firstNameTextBox and lastNameTextBox for users’ input. There is also a Label control named fullNameLabel. Write C# statement(s) to combine the first and the last names with a space in between and display the full name in the fullNameLabel. (proper Variables Must be declared)
USING C#
Here, your requirement is only only for the statement. So I am not providing you whole code for that
In your application,
firstNameTextBox has first name value.
You can get it by firstNameTextBox.Text
lastNameTextBox has last name value.
You can get it by lastNameTextBox.Text
To set the given value to fullNameLabel contol, you can use fullNameLabel.Text
means fullNameLabel.Text = "Whatever you want to set"
So, to append first name and last name and show it in label field code is as below.
string firstName, lastName;
firstName = firstNameTextBox.Text; //get firstname
lastName = lastNameTextBox.Text; //get lastname
fullNameLabel.Text = firstName + " " + lastName //append firstname and lastname using space
OR
Second method is you can directly add without assignment as below
fullNameLabel.Text = firstNameTextBox.Text + " " + lastNameTextBox.Text; //append firstname and lastname using space
Get Answers For Free
Most questions answered within 1 hours.