I'm trying to make a really basic calculator program. I am getting the following error message:
Cannot implicitly convert type 'bool' to 'string'
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _2019_03_21
{
class Program
{
private static double Negyzet(int alap, int kitevo)
{
Console.WriteLine("Kérem a hatvány alapját!");
alap = int.Parse(Console.ReadLine());
Console.WriteLine("Kérem a hatvány kitevojet!");
kitevo = int.Parse(Console.ReadLine());
return Math.Pow(alap, kitevo);
}
static void Main(string[] args)
{
Console.WriteLine("Kérem adja meg milyen műveletet szeretne elvégezni!\n\n+ összeadás\n- kivonás\n* szorzás\n/ osztás\n^hatványozás\n\nVálasztott művelet:");
string muvelet = Console.ReadLine();
switch (muvelet)
{
case (muvelet == "^"): Console.WriteLine("A hatvány értéke: {0}", Negyzet(0, 0)); break;
default: break;
}
Console.ReadKey();
}
}
}
If expr and constant are integral types, the C# equality operator determines whether the expression returns true (that is, whether expr == constant). Otherwise, the value of the expression is determined by a call to the static Object.Equals(expr, constant) method.ifandswitchis that the latter might make use of a lookup table, if possible, which is much faster when many clauses are needed, while the former always evaluates the clauses consecutively.