[MonoDevelop] A little more help required

Sanford Armstrong sanfordarmstrong at gmail.com
Wed Nov 15 23:26:39 EST 2006

On 11/15/06, Neil Munro <neilmunro at gmail.com> wrote:
> public class MainWindow: Gtk.Window
> {
>     protected Gtk.Entry entryNum2;
>     protected Gtk.Entry entryNum1;
>         //convert strings to ints
>         int iNum1 = Convert.ToInt32(entryNum1);
>         int iNum2 = Convert.ToInt32(entryNum2);

Here's a problem.  You are trying to convert Gtk.Entry objects into
integers.  You probably want to convert the text in the entry to an
integer instead.  So you'll need to follow the example of some of your
other code, and make those lines look something like:

int iNum1 = Convert.ToInt32(entryNum1.Text);

Trying to convert a Gtk.Entry into an integer is probably throwing an
exception, which causes your program to crash.

What widget is the OnDeleteEvent connected to?  Poking around in the
stetic designer should give you a clue if you're not sure.  That could
also be causing your app to quit prematurely.

It might be a fun exercise for you to handle the situation where a
user tries to enter letters into the number entry fields.  There are
several ways you could solve that problem that might help you get
familiar with C# and GTK.


More information about the Monodevelop-list mailing list