I keep getting this error when making the program as given below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace simplecalc
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
int a, b, c;
a = int.Parse(textBox1.Text);
b = int.Parse(textBox2.Text);
if (rbadd.Checked == true)
c = a + b;
else if (rbsubtract.Checked == true)
c = a - b;
else if (rbdivide.Checked == true)
c = a / b;
else
c = a * b;
textBox3.Text = c.ToString();
}
}
}
I am in the process of making a basic calculator in C# in WPF. I am very new to C#.
Checkedhere is an event, not abool, that happens when it is checked. You need a different property – presumablyIsChecked.Minor note, but stylistically, it is usually preferable not to compare booleans to
true/false, but rather:etc; or if you wanted to test for
false:if(!rbadd.IsChecked).