0

I'm trying to learn C# from this tutorial: http://rbwhitaker.wikidot.com/c-sharp-enumerations

It suggests defining "today" as you see below, but when I do I get this error: 'EnumerationTutorial.DaysOfWeek' does not contain a definition for 'today'

I have tried many different things, but I can't figure out what I'm doing wrong.

Thanks for your help.

https://i.sstatic.net/gi4wB.png

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.Net;

namespace EnumerationTutorial
{
    public enum DaysOfWeek { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };

    public class Program
    {
        static void Main(string[] args)
        {
            DaysOfWeek today = DaysOfWeek.Sunday;
            Console.WriteLine(DaysOfWeek.today);
            Console.ReadLine();
        }
    }
}
1
  • 1
    today is an instance of Sunday member of your DaysOfWeek enum. Your DaysOfWeek doesn't have any member called today. Feels like you just want to Console.WriteLine(today) instead. Commented Nov 9, 2014 at 11:42

1 Answer 1

3

This declares a variable of type DaysOfWeek named today

        DaysOfWeek today = DaysOfWeek.Sunday;

This accesses the today member of DaysOfWeek, which does not exist

        Console.WriteLine(DaysOfWeek.today);

Try this instead

        Console.WriteLine(today);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help Eric, that worked and helped clear it up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.