If there is something I understand least of in programming, it's accessing arrays. Does anyone know why this won't work? I can't find the answer anywhere. What I'm basically trying to do is take the months that have 30 days and perform a math problem, but I can't seem to access the array. 'month' is a string. It is giving me the error: Operator '==' cannot be applied to operands of type 'string' and 'string[]. Not sure what that means. I've looked for the error, googled it and whatnot but I can't find any answers anywhere. I appreciate any help.

string[] months30 = new string[4] { "September", "April", "June", "November" };



            if (month == months30)
            {

            }

An array is a collection of items. To access individual items you need to specify which index in the collection you want (ranging from 0 to N-1):

for (int i = 0; i < months30.Length; i++)
{
    if (months30[i] == month) // Now you can test against the entered month
    {
        Console.WriteLine("{0} has 30 days", month);
    }
}

months30' is a string array (string[]) while, and I'm assuming here, 'month' is of type string.' Since they aren't the same type, you can't really compare them.

If you want to find if 'month' is in the array 'months30' you'll have to iterate through the array and compare elements.

This question has already been answered. Start a new discussion instead.