Why doesn't the slightest change to a Hello World program run?

B

Bupkas

using System.Windows.Forms;

class MessageBoxHelloWorld

{

public static void Main()

{

MessageBox.Show("Hello, world!", "MessageBoxHelloWorld"); // Runs ok

MessageBox.Show("Hello, world!", "MessageBoxHelloWorld",
MessageBoxButtons.Abort); // Doesn't compile

}

}
 
M

Mickey Williams

There's no such value as MessageBoxButtons.Abort. If you want the abort
button, you need to specify MessageBoxButtons.AbortRetryIgnore.
 
B

Bupkas

Thanks. Orignally when I caused the error I had the line,

System.Windows.Forms.MessageBox.Show("string1","string2",MessageBoxButtons.O
KCancel);

which still doesn't work. However, when I introduced "using" in the
following line,
using System.Windows.Forms;

and then abridged the one line to,

MessageBox.Show("Hello, world!", "MessageBoxHelloWorld",
MessageBoxButtons.OKCancel);

I introduced the error to "MessageBoxButtons.Abort" while playing with
"MessageBoxIcon.

Now it works. I guess the "using" line is necessary for some reason.

Appreciation expressed. :)
 
?

=?iso-8859-1?Q?Andreas_H=E5kansson?=

Bupkas,

The using statement is required because the MessageBox class
is located in the System.Windows.Forms namespace. Without the
using statement you could have to use the fullname or not use the
class at all =)

HTH,

//Andreas

--
ANDREAS HÅKANSSON
STUDENT OF SOFTWARE ENGINEERING
andreas (at) selfinflicted.org
Thanks. Orignally when I caused the error I had the line,

System.Windows.Forms.MessageBox.Show("string1","string2",MessageBoxButtons.O
KCancel);

which still doesn't work. However, when I introduced "using" in the
following line,
using System.Windows.Forms;

and then abridged the one line to,

MessageBox.Show("Hello, world!", "MessageBoxHelloWorld",
MessageBoxButtons.OKCancel);

I introduced the error to "MessageBoxButtons.Abort" while playing with
"MessageBoxIcon.

Now it works. I guess the "using" line is necessary for some reason.

Appreciation expressed. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top