troubles declaring static enum, C#

RayLoveless picture RayLoveless · Dec 31, 2010 · Viewed 68.2k times · Source

Hi I'm trying to declar a static enum like so:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Lds.CM.MyApp.Controllers
{
    public class MenuBarsController : Controller
    {
        // Menu Bar enums
        public static enum ProfileMenuBarTab { MainProfile, Edit, photoGallery }

        public ActionResult cpTopMenuBar(string tabSelected)
        {
            ...            

" But I'm getting the following error: "The modifier 'static' is not valid for this item." I know it's something simple but I can't seem to see the problem. Much thanks!

Answer

magnattic picture magnattic · Dec 31, 2010

Enums are types, not variables. Therefore they are 'static' per definition, you dont need the keyword.

public enum ProfileMenuBarTab { MainProfile, Edit, PhotoGallery }