C# compile error for simple Annual Salary Calculator
- by Mike Vignapiano
I am new to C# and trying to create my 1st app.
I have 3 errors. The first two say that txtSalary and Salary do not exist.
The 3rd says that it
cannot convert method group 'ToString' to non-delegate type 'string'.
and asks if I intend to invoke the method.
Here is what I have:
protected void Button1_Click(object sender, EventArgs e)
{
int salary, AnnualHours, Rate;
string txtAnnualHours, txtSalary, txtRate;
salary = AnnualHours * Rate;
txtsalary = int.Parse(Salary);
txtAnnualHours = salary.ToString;
MessageBox.Show(salary);
}
According to my book, when you enter numerics in AnnualHours and Rate textbox, when click Button1, these values are converted from string to integers, then multiplied for salary.
Then numeric answer converted to string and displayed in messagebox named txtSalary.
Please show me what I got wrong because according to the book, I am not missing anything.