CS1955 Non-invocable member ‘pieceworkForm.calcButton’ cannot be used
like a method.
Instead of calling a method you are calling an event handler. What you want to do is the following:
float pay = calc(pieces);
CS0266 Cannot implicitly convert type ‘double’ to ‘float’. An explicit
conversion exists (are you missing a cast?)
You need to specify your real numbers as a float in order to save them into a float variable, as they are a double by default.
private float calc(int pieces)
{
float pay = 0f;
switch (pieces)
{
case 0:
pay = 0f;
break;
case 1: // 1 to 199
pay = pieces * 0.5f;
break;
case 2: // 200 to 399
pay = pieces * 0.55f;
break;
case 3: // 400 to 599
pay = pieces * 0.6f;
break;
default:
pay = pieces * 0.65f;
break;
}
return pay;
}
CS1620 Argument 2 must be passed with the ‘out’ keyword.
Passing any values by reference must be explicitly defined using the out keyword. You can read about it on MSDN.
if ((int.TryParse(piecesTextBox.Text.Trim(), out pieces)))
{
calcButton.Enabled = true;
}
solved C# programming error questions?