C# Programming
08-26-2009, 02:02 PM
Im not sure if i did the right thing to post here, i went through a few threads and i couldnt figure this thing out. sorry it's my first message, also im just learning c# and i have no idea wat error i have..
Should i post this somewhere else or create a message everytime?
This is my program:
using System;
class Work1
{
public static void Main()
{
int amount;
Console.WriteLine("Enter wage");
int wage = Console.ReadLine();
Console.WriteLine("Enter hours");
int hours = Console.ReadLine();
amount = (hours * wage);
Console.WriteLine("Amount = ", amount);
Console.ReadLine();
}
}
Im trying to learn c# and tried something very simple. wage*hours = my money. but of course i failed doing so.
Error 1 Cannot implicitly convert type 'string' to 'int' C:\Users\Saliba\Documents\Visual Studio 2008\Projects\Project2\Project2\Class1.cs 12 19 Project2
//refers to this line = int wage = Console.ReadLine();
Error 2 Cannot implicitly convert type 'string' to 'int' C:\Users\Saliba\Documents\Visual Studio 2008\Projects\Project2\Project2\Class1.cs 15 25 Project2
//refers to this line = int hours = Console.ReadLine();
those are the errors.
i know its pretty frustrating for admins and moderators to stay deleting/ moving posts. im sorry if this is the case.
thanks for future help, Luke
Should i post this somewhere else or create a message everytime?
This is my program:
using System;
class Work1
{
public static void Main()
{
int amount;
Console.WriteLine("Enter wage");
int wage = Console.ReadLine();
Console.WriteLine("Enter hours");
int hours = Console.ReadLine();
amount = (hours * wage);
Console.WriteLine("Amount = ", amount);
Console.ReadLine();
}
}
Im trying to learn c# and tried something very simple. wage*hours = my money. but of course i failed doing so.
Error 1 Cannot implicitly convert type 'string' to 'int' C:\Users\Saliba\Documents\Visual Studio 2008\Projects\Project2\Project2\Class1.cs 12 19 Project2
//refers to this line = int wage = Console.ReadLine();
Error 2 Cannot implicitly convert type 'string' to 'int' C:\Users\Saliba\Documents\Visual Studio 2008\Projects\Project2\Project2\Class1.cs 15 25 Project2
//refers to this line = int hours = Console.ReadLine();
those are the errors.
i know its pretty frustrating for admins and moderators to stay deleting/ moving posts. im sorry if this is the case.
thanks for future help, Luke