A
A
ArlekinSX2020-03-02 17:48:43
C++ / C#
ArlekinSX, 2020-03-02 17:48:43

Where are the InputBox functions?

Guys, can anyone in the know, tell me please.
I'm learning C# by book, practicing with Visual Studio. There was a problem during the next exercise:
When you enter the variable name=Interaction.InputBox( , the InputBox function is highlighted with a red underline. The error says "object" does not contain the definition of "InputBox", and it was not possible to find an available extension method "InputBox" that accepts the type "object " as the first argument (perhaps missing a using directive or an assembly reference). .
Here is all the code spelled correctly in the exercise:
// Using Visual Basic resources:
using Microsoft.VisualBasic;
using System.Windows.Forms;
{
public static object Interaction { get; private set; }

static void Main()
{
// Text variable:
string name;
// Displaying a window with an input field:
name=Interaction.InputBox(
"What's your name?", // Text above the input field
"Let's get acquainted..."// Window name
);
// Another text variable:
string txt = "Very nice, " + name + "!";
// Message box:
MessageBox.Show(txt, "Introduction took place");
}
}
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
#
#, 2020-03-02
@ArlekinSX

in Visual Studio there is a system of hints and even corrections of the code / project settings
just on the error line, carefully look at what the studio prompts

A
ArlekinSX, 2020-03-02
@ArlekinSX

Guys, the problem was in class InputDialogDemo , I didn't put curly brace at the end {

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question