none
The type or namespace 'EmpType' could not be found (are you missing a using directive or an assembly reference?)

    Question

  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;


    namespace FunWithEnums
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("**** Fun with Enums *****");
                // Make a contractor type.
                EmpType emp = EmpType.Contractor;
                AskForBonus(emp);
                Console.ReadLine(); 
            }

            // Enums as parameters.
            static void AskForBonus(EmpType e)
            {
                switch (e)
                {
                    case EmpType.Manager:
                        Console.WriteLine("How about stock options instead?");
                        break;
                    case EmpType.Grunt:
                        Console.WriteLine("You have got to be kidding...");
                        break;
                    case EmpType.Contractor:
                        Console.WriteLine("You already get enough cash...");
                        break;
                    case EmpType.VicePresident:
                        Console.WriteLine("VERY GOOD, Sir!");
                        break;
                }
            }
        }

    }
    Thursday, January 10, 2013 2:34 PM

Answers

  • What's the question?

    somewhere, in your code or a referenced library you need to declare it... at the minimum this might be

    enum EmpType { Manager, Grunt, Contractor, VicePresident }


    This signature unintentionally left blank.

    • Marked as answer by SegunP Thursday, January 10, 2013 3:11 PM
    Thursday, January 10, 2013 2:36 PM

All replies

  • What's the question?

    somewhere, in your code or a referenced library you need to declare it... at the minimum this might be

    enum EmpType { Manager, Grunt, Contractor, VicePresident }


    This signature unintentionally left blank.

    • Marked as answer by SegunP Thursday, January 10, 2013 3:11 PM
    Thursday, January 10, 2013 2:36 PM
  • The type or namespace 'EmpType' could not be found (are you missing a using directive or an assembly reference?)

    Thursday, January 10, 2013 2:44 PM
  • You are missing at least one of:

    - a type named EmpType

    - a 'using' directive with the namespace of the EmpType type

    - a reference to the assembly containing the EmpType type

    Thursday, January 10, 2013 3:00 PM
  • The answer to that question is YES.

    Something is missing from your code, and in my first reply I hinted at what that something is.  I'll be happy to help you but I can't read minds that are so far away, so you need to provide more information.  the better your explanation and the more detail you provide, the easier it is to give you an accurate and complete answer.


    This signature unintentionally left blank.

    Thursday, January 10, 2013 3:03 PM
  • Thank you very much Nick, it worked. I didn't declare enum EmpType { Manager, Grunt, Contractor, VicePresident }
    • Edited by SegunP Thursday, January 10, 2013 3:16 PM
    Thursday, January 10, 2013 3:12 PM