Can you help me with this? I'm getting this error in my code:
Cannot implicitly convert type 'bool' to 'string'
I've searched on the internet to fix this and saw stackoverflow questions still not fixed. The code is
using System;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("How are you?");
string choice = bool.Parse(Console.ReadLine()); //Error in this line
if (choice == "Fine" || choice == "Good" || choice == "doing well")
{
Console.WriteLine("It's great to know that you're" + choice);
}
else if (choice == "bad" || choice == "not good" || choice == "not so well")
{
Console.WriteLine("What happened? Why" + choice + "?");
}
}
}
}
A question in stackoverflow recommended me to use bool.Parse or bool.TryParse before ReadLine. Used so but still errors.
Aucun commentaire:
Enregistrer un commentaire