If statement help [SOLVED]
Posted: Mon Jan 16, 2012 1:46 am
Sorry if this isn't the right topic, please let me know if it isn't and i will move the post to the right topic.
So i'm trying to build a basic calculator in C# to test myself, and so far i have this code
I'm going to have each of the if statements call its respective class, for example if the user inputs "1" It will call the addition class.
However the problem i'm having is that i'm getting this error
"
Error 1 Cannot implicitly convert type 'int' to 'string' C:\Users\Matt\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 18 30 ConsoleApplication1
"
What does it mean? And how should I go about fixing it.
Thanks in advanced!
~Matt
So i'm trying to build a basic calculator in C# to test myself, and so far i have this code
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1. Addition");
Console.WriteLine("2.Subtraction");
Console.WriteLine("3.Multiplication");
Console.WriteLine("4.Division");
string menuchoice = Console.ReadLine();
if (menuchoice = 1)
{
}
if (menuchoice = 2)
{
}
if (menuchoice = 3)
{
}
if (menuchoice = 4)
{
}
}
}
}However the problem i'm having is that i'm getting this error
"
Error 1 Cannot implicitly convert type 'int' to 'string' C:\Users\Matt\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 18 30 ConsoleApplication1
"
What does it mean? And how should I go about fixing it.
Thanks in advanced!
~Matt