I have an assignment for TAFE in which i have to create a console program in Visual Studio that calculates the cost of a consultation based on consultation time (at $25 an hour).
string hours, rate, total;
Console.Write("Enter consultation time in hours");
hours = Console.ReadLine();
rate = ;
total = hours * rate;
Console.WriteLine("Fee is " + total);
My problem is on line 5, I get the error "operator '*' cannot be applied to operands of type 'string' and 'string;"
Can someone explain to me what is wrong, why 2 strings cant be multiplied and also supply an alternate method of getting that line to work?
EDIT: Thank you everyone. All info given was helpful. I've completed it leaving the rate as an Integer as its a set value not changed by user input, the hours and total are still strings, The hours converting to decimal via the convert.ToDecimal line GianlucaBobbio gave me. The only problem now is console doesnt stay open after calculating rate * hour, but i can fix that.
You may just have a new regular user :D! appreciate the help. you're all life savers :)