Estou começando a me aventurar no C#, porém estou obtendo o erro
"CS1501 C# No overload for method takes 2 arguments"
O código é muito simples e provavelmente não contém erro, pois estou usando o código disponibilizado (via download) pelo autor do livro que estou seguindo, conforme abaixo.
Código:
namespace ClassDemo
{
class Staff
{
private string nameOfStaff;
private const int hourlyRate = 30;
private int hWorked;
public int HoursWorked
{
get
{
return hWorked;
}
set
{
if (value > 0)
hWorked = value;
else
hWorked = 0;
}
}
public void PrintMessage()
{
Console.WriteLine("Calculating Pay...");
}
public int CalculatePay()
{
PrintMessage();
int staffPay;
staffPay = hWorked * hourlyRate;
if (hWorked > 0)
return staffPay;
else
return 0;
}
public int CalculatePay(int bonus, int allowance)
{
PrintMessage();
if (hWorked > 0)
return hWorked * hourlyRate + bonus + allowance;
else
return 0;
}
public override string ToString()
{
return "Name of Staff = " + nameOfStaff + ", hourlyRate = " + hourlyRate + ", hWorked = " + hWorked;
}
public Staff(string name)
{
nameOfStaff = name;
Console.WriteLine("\n" + nameOfStaff);
Console.WriteLine("--------------------------");
}
public Staff(string firstName, string lastName)
{
nameOfStaff = firstName + " " + lastName;
Console.WriteLine("\n" + nameOfStaff);
Console.WriteLine("--------------------------");
}
}
class Program
{
static void Main(string[] args)
{
int pay;
Staff staff1 = new Staff("Peter");
staff1.HoursWorked = 160;
pay = staff1.CalculatePay(1000, 400);
Console.WriteLine("Pay = {0}", pay);
Staff staff2 = new Staff("Jane", "Lee");
staff2.HoursWorked = 160;
pay = staff2.CalculatePay();
Console.WriteLine("Pay = {0}", pay);
Staff staff3 = new Staff("Carol");
staff3.HoursWorked = -10;
pay = staff3.CalculatePay();
Console.WriteLine("Pay = {0}", pay);
Console.Read();
}
}
}