Really simple question on 'msgbox'

C

COHENMARVIN

I'm a VB programmer, learning C#. How does one do the equivalent of a
"msgbox" (from Visual Basic) in C#? Is there something like this:
System.Forms.MessageBox("Hello World");
Thanks,
Marvin
 
G

Gilles Kohl [MVP]

Hi Marvin,

I'm a VB programmer, learning C#. How does one do the equivalent of a
"msgbox" (from Visual Basic) in C#? Is there something like this:
System.Forms.MessageBox("Hello World");
Thanks,
Marvin

You almost guessed it alreadyt:

System.Windows.Forms.MessageBox.Show("Hello World");

(don't forget the semicolon :)

Btw., don't worry - you won't have to retype that lengthy namespace, just add

using System.Windows.Forms;

at the top of your .cs file, if the "New Project" wizard did not do that for
you already.

Then, just use e.g.

MessageBox.Show("Hello World");

(There's lots of alternatives btw, if you are using Visual Studio, try opening
the curling brace after typing "Show" and srcoll through them with cursor up
and down)

Have fun with C#!

Regards,
Gilles.
 

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