C# compile error for simple Annual Salary Calculator
Posted
by
Mike Vignapiano
on Stack Overflow
See other posts from Stack Overflow
or by Mike Vignapiano
Published on 2013-11-04T00:36:13Z
Indexed on
2013/11/04
3:54 UTC
Read the original article
Hit count: 167
c#
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.
© Stack Overflow or respective owner