Banking object1 = new Banking(t1.Text);
MessageBox.Show(object1.transact(t2.Text));
It's giving an error of invalid arguments in the method and also that it cant convert from String to float. Banking
is the class and object1
is an object, transact is a method. As long as I believe there is no error in the method still below I'm pasting my class and method code:
class Banking
{ string bankName;
float amount;
public Banking(string name)
{
bankName = name;
}
public string transact(float a)
{
amount = a * 7 / 100;
float total =Convert.ToSingle(amount + a);
return "Your amount of Rupees : " + total + "has been deposited in " + bankName;
}
}
Here is the error list:
Error 1 The best overloaded method match for 'WindowsFormsApplication1.Banking.transact(float)' has some invalid arguments.
Error 2 Argument '1': cannot convert from 'string' to 'float'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.