Results 1 to 6 of 6

Thread: Enumeration in Interface

  1. #1

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Resolved Enumeration in Interface

    Can one create a variable of which the type is an enumeration in an Interface class?

    For instance:

    I created an interface called IResource. The resource will either be a code file, image, document, etc.

    So, I want to create an enumeration (ResourceTypes), and in the interface declare a property "ResourceType" whose value will be a member of the ResourceTypes enumeration, and will be set in derived classes.

    I'm new to actually using interfaces, etc
    Last edited by StrangerInBeijing; Oct 8th, 2005 at 09:17 PM. Reason: Resolved
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Enumeration in Interface

    You can do it, but I'm not aware of any enumerated types that are members of an interface. All the enumerated types I can think of are members of a namespace directly and not nested within a class or other type.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: Enumeration in Interface

    Oi, I did not know that!
    I just created the enumeration BEFORE the class declaration, and it works.
    Thought everything got to be inside a class. Little confused, but will look into it.
    Some explanation would be welcome though.
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Enumeration in Interface

    An enumeration is a type in itself, so you can define one anywhere you can define a class, or any other type for that matter. It can be nested within another type, like a class or interface, or it can be defined elsewhere in a code file. You might define it in the same file as a class, but outside the class definition, or you could define it in its own code file, along with other types or on its own.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: Enumeration in Interface

    Thanks matey!
    Wonder how many other things is there I don't have a clue about.
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  6. #6
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Enumeration in Interface

    Quote Originally Posted by StrangerInBeijing
    I just created the enumeration BEFORE the class declaration
    That means it is in the same namespace as the class who's declaration follows it's declaration.
    There is actually no link between them, other than being declared in the same file.

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