1

I'm new user of Xamarin studio 5.9.5 (build 9) on Windows, and I want make a form based application that involves some mathematical calculations (.Net + Gtk#).

I made a simple form containing 3 Entry widgets (2 for input values and 1 for output value) and 1 button. Here is the code for the button (simple addition Entry3 = Entry1 + Entry2)

using System;
using Gtk;
...    
protected void OnBtnClicked (object sender, EventArgs e)
        {
            entry3.Text = entry1.Text + entry2.Text;
            //throw new NotImplementedException ();
        }

As you can see, this code just makes a concatenation of both text fields.

How can I convert the text fields into numeric values in order to achieve mathematical addition (and other calculations) ?

Thanks

Issak Sdu
  • 29
  • 2
  • 7

1 Answers1

4
// assuming these values are ints
int val1 = int.Parse(entry1.Text);
int val2 = int.Parse(entry2.Text);
entry3.Text = val1 + val2;
Jason
  • 86,222
  • 15
  • 131
  • 146