Hello, everyone!
I made this calculator in C# linked to XAML, and it works perfect, however, part of the assignment for the school ask for overloaded methods and for methods with arguments modifiers, too. Is that possible? Is possible to have overloaded methods and methods with arguments for event handlers? Or do I need to remake my calculator without event handlers. I just need some advise, please. Thanks
This is the C# code for adding and resting, rest is the same, just changes name of the math operations.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void button1_click(object sender, EventArgs e)
{
var btn = sender as Button;
var key = btn.Text;
float num1;
float num2;
float sum;
num1 = Convert.ToInt32(number1.Text);
num2 = Convert.ToInt32(number2.Text);
sum = num1 + num2;
label3.Text = "Result is "+ sum;
}
private void button2_click(object sender, EventArgs e)
{
var btn = sender as Button;
var key = btn.Text;
int num1;
int num2;
int rest;
num1 = Convert.ToInt32(number1.Text);
num2 = Convert.ToInt32(number2.Text);
rest = num1 - num2;
label3.Text = "Result is " + rest;
}
What I have tried:
I have tried many ways:
-Like adding object sender1 instead of object sender from one of the methods
-Deleting object sender from one of the methods
-Deleting EventArgs e from one of the methods
-Adding string s after EventArgs to one of the methods and then use it like
{
MessageBox.Show(s)
}
Nevertheless, Nothing seems to work.
Thanks