Fair warning, I'm a complete beginner in this language.
I want to put together a simple quiz using C# that asks for user input for a favorite color, and then puts out a response based on what they type in. Right now I'm just using a bunch of if statements to check the inputs, but that requires me to copy/paste those if statements for every color. Is there a way I can use an array of some sort that'll let me put all the colors and responses together? I know you can use an array for numbers, but I can't figure out if you can do the same for words.
Again, I'm a pretty bare bones beginner, so if this is a stupid question, I apologize.
Sorry, here's my code:
using System;
namespace Whee
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("What is your favorite color?");
string color = Console.ReadLine();
if (color == "blue")
{
Console.WriteLine ("You must be a calm person.");
}
if else (color == "red")
{
Console.WriteLine ("You must be a Sith Lord.");
}
if (color == "green")
{
Console.WriteLine ("Dolla bills y'all!");
}
if (color == "orange")
{
Console.WriteLine ("What is this I don't even");
}
else
{
Console.WriteLine ("You fail at colors. Try again.");
}
}
}