Re: Help with a simple enum error
From: Dmitriy Lapshin [C# / .NET MVP] (x-code_at_no-spam-please.hotpop.com)
Date: 02/26/04
- Next message: Leon Lambert: "Re: return statements and try catch finally blocks"
- Previous message: Mohamoss: "RE: ASP.NET, DataGrid & array."
- In reply to: Simon Harvey: "Help with a simple enum error"
- Next in thread: Jon Skeet [C# MVP]: "Re: Help with a simple enum error"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Feb 2004 15:06:14 +0200
Hi Simon,
> Can anyone see what I've done wrong? I know its going to be something
> totally obvious but I cant see it!
You should cast the enumeration item to int:
if(roleID <= (int)RolesEnumeration.GolbalAdmin)
given roleID is an "int" variable.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://www.x-unity.net/teststudio.aspx Bring the power of unit testing to VS .NET IDE "Simon Harvey" <simon.harvey@the-web-works.co.uk> wrote in message news:OXldWaG$DHA.4012@tk2msftngp13.phx.gbl... > Hi all, > > I thought that if I declared an Enum as follows: > > public enum RolesEnumeration{ > GlobalAdmin = 0, > PrincipalTrialInvestigator = 1, > TrialManager = 2, > AssistantTrialManager = 3, > GroupCoordinator = 4, > GroupTrialManager = 5, > GroupDataManager = 6, > ClinicalResearchAssistant = 7, > StudyManagementCommittee = 8, > PrincipalSiteInvestigator = 9, > SiteCoInvestigator = 10, > SiteStudyNurses = 11, > Patient = 12, > IndustryUser = 13, > Others = 14, > LabResearcher = 15, > DataAndEthicsMonitoringCommittee = 16 > } > > Then I could make a statement like: > if(roleID <= RolesEnumeration.GolbalAdmin){ > ... > > At the moment though, the compiler is telling me that: > Operator '<=' cannot be applied to operands of type 'int' and > 'spirit.secure.RolesEnumeration' > > Can anyone see what I've done wrong? I know its going to be something > totally obvious but I cant see it! > > Thanks all > > Simon > >
- Next message: Leon Lambert: "Re: return statements and try catch finally blocks"
- Previous message: Mohamoss: "RE: ASP.NET, DataGrid & array."
- In reply to: Simon Harvey: "Help with a simple enum error"
- Next in thread: Jon Skeet [C# MVP]: "Re: Help with a simple enum error"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|