Question: In c# I am trying to get this code to display at the bottom in a windows form app in c#. It is giving me
In c#
I am trying to get this code to display at the bottom in a windows form app in c#. It is giving me the error that I cannot implicitly convert from a string to System.Windows.Forms.Label. Any suggestions as to how to fix this code so that it replaces what i have typed out as "lblResults = " into the text section of the label (currently no text is inside).
private void lblResults_Click(object sender, EventArgs e) { string name; string destination; string milesTraveledString; string gallonsConsumedString; double milesTraveled; double gallonsConsumed;
name = txtbxName.Text; destination = txtbxDestination.Text; milesTraveledString = txtbxDestination.Text; gallonsConsumedString = txtbxGallonsConsumed.Text; milesTraveled = double.Parse(milesTraveledString); gallonsConsumed = double.Parse(gallonsConsumedString);
lblResults = "Your name is: " + name + " Your Destination is: " + destination + " Your Miles Per Gallon for the trip will be: " + gallonsConsumed; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
