Reputation: 11
I have tried to make an InputBox in C#, I have managed to figure out how do this however, now I cannot extract an answer. Whenever I try to extract an answer it keeps coming up with the following error: "Cannot implicitly convert type 'string' to System.Windows.Forms.Label'." The code I have written so far is below.
private void devBtn1_Click(object sender, EventArgs e)
{
string bluePlyr1;
bluePlyr1 = Microsoft.VisualBasic.Interaction.InputBox("Name of Player 1");
devLbl1 = bluePlyr1;
}
Thanks in advance.
Upvotes: 0
Views: 77
Reputation: 18165
C#, unlike Visual Basic, does not have "default" properties. While your assignment of devLbl1 = bluePlyr1
would work in VB (because Text
is the default property of a label) it won't work in C#. You need to specify the property you're trying to set.
devlbl1.Text = bluePlyr1;
Upvotes: 1