[Mono-devel-list] C# Program on MONO

Jonathan Pryor jonpryor at vt.edu
Wed Jan 12 07:29:03 EST 2005


On Wed, 2005-01-12 at 11:22 +0530, Umashankar Ashwathnarayanan wrote:
> HI , I want to Run the Simple Program of Displaying the Message Box that 
> is developed in C#  on Linux
> Using  MONO .
>  Can u plz  send the step that  should be followed .

This would be done using Gtk#.

First, save the following source code into a file named "md.cs":

	// file: md.cs
	//
	// Gtk# MessageDialog Example (from MonoDoc)
	using Gtk;

	class MessageDialogExample {
		public static void Main ()
		{
			Application.Init ();              // Initialize Gtk# library

			MessageDialog md = new MessageDialog (
			  null,                           // parent window
			  DialogFlags.DestroyWithParent,  // specifies dialog behavior
			  MessageType.Info,               // controls icon displayed
			  ButtonsType.Close,              // Button(s) to display
			  "Insert message here");         // Message to display

			int result = md.Run ();           // Display the dialog
			                                  // result contains the button clicked
			md.Destroy();                     // Cleanup Resources
		}
	}

Next, compile the program:

	mcs -pkg:gtk-sharp md.cs

The "-pkg" argument is used so that the gtk-sharp assemblies are
properly referenced.

Execute the program with:

	mono md.exe

For more information, see:

	http://www.go-mono.com/docs/index.aspx?link=N%3aGtk
	http://www.go-mono.com/docs/index.aspx?link=T%3aGtk.MessageDialog

 - Jon





More information about the Mono-devel-list mailing list