CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #6
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: RESOLVED: Re: Use enum from another class?

    Quote Originally Posted by purpleflash
    ....can someone explain why I have to cast to int since there is a reference to the class that contains the enumeration? I would think the cast would be unnecessary.....
    When your SetContainerType is like
    Code:
    public void SetContainerType(int type){
    .... 
    }
    Then you need to cast. as you are awaiting an integer here
    if instead of this you have
    Code:
    public void SetContainerType(ContainerTypes type){
    ...
     
    }
    then this works without troubles. May I ask why you have it this way ?
    Code:
    public class class1
    	{
    		[FlagsAttribute]
    		public enum ContainerTypes : int
    		{
    			CT_OUTLOOK = 0,
    			CT_XML = 1,
    			CT_SDX = 2,
    			CT_SAP = 4
    		};
    	}
    Instead of this
    Code:
    public enum ContainerTypes : int
    		{
    			CT_OUTLOOK = 0,
    			CT_XML = 1,
    			CT_SDX = 2,
    			CT_SAP = 4
    		};
     
    public class class1 {
    ...whatever needs using your enum here
    }
    as the enum is public its quite useless to put it into the class, isn't it ? And use singular names for enum as you in every case have one of them.
    Last edited by JonnyPoet; September 30th, 2007 at 05:18 AM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured