Results 1 to 4 of 4

Thread: Static class problems

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Static class problems

    I am struggling to get my pea brain around this one.

    I want to create a static class which holds an enumeration. Something like :

    VB Code:
    1. Static class enumTypes
    2. {
    3.  
    4. public enum choice
    5. {
    6. choice1, choice2
    7. }
    8.  
    9. }
    I want to be able to do something like this :

    VB Code:
    1. If (myThingy = enumTypes.choice.choice1)
    2. {
    3. //do something
    4. }
    5. else
    6. {
    7. //do something else
    8. }

    The exact syntax is troubling me because I am silly.

    Parksie

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Syntax is fine , what's the error message ?

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

    Re: Static class problems

    I strongly recommend that you don't do that. How many enumerations can you name in the .NET Framework that are nested within a class? None that I'm aware of. An enumeration should be declared as a member of the appropriate namespace and that's it.

    As for your code, a single '=' in C# is an assignment. For comparisons use the double '=='.
    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

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Static class problems

    oops !

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