Tuesday, 13 August 2013

C# String multiplication error

C# String multiplication error

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?
Thanks :)
Also, First post, Be friendly please.

No comments:

Post a Comment