vendredi 18 septembre 2020

C# Possible to use If statements to choose different variables depending on user input?

Will If Statement not work for choosing variables depending on user input? What should I use instead?

        Console.WriteLine("Are you female?");
        string answer = Console.ReadLine();
        if (answer == "Yes" || answer == "yes" || answer == "YES")
        {
            string type = She, status = woman;
        }
        else
        {
            string type = He, status = man;
        }
        Console.WriteLine(type + " was a " + status + ".");
        Console.ReadLine();

Aucun commentaire:

Enregistrer un commentaire