Re: Help with a simple enum error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dmitriy Lapshin [C# / .NET MVP] (x-code_at_no-spam-please.hotpop.com)
Date: 02/26/04


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
>
>


Relevant Pages

  • Re: Windows Form Dictionary
    ... database, not in seperately html file. ... intBookId (INT) ... i cant use html file or tag or link style or other ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Type missmatch, cant convert from int to object.
    ... "Juggernaut" wrote in message ... But I get that a type missmatch where it cant convert from ... That won't work because an int isn't an object. ... In the future, post executable code that ...
    (comp.lang.java.programmer)
  • Re: Windows Form Dictionary
    ... intBookId (INT) ... I show this content in webBrowser  control. ... i cant use html file or tag or link style or other ... I obtain the word which double click with javascript, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: use delete to destroy primitive/object types but memory is not freed
    ... I cant understand why if I am off topic an answer exists in the C-faq. ... int main{ ... Please why dont you try to ...
    (comp.lang.c)
  • help with those darn INT and STRING thingys!!!!!!!
    ... i just cant get this. ... noticed that a lot are on this topic, but i dont really understand what they ... but the program doesnt recognise the input ... magically use it as an int. ...
    (comp.lang.java.help)