enum Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barry

    enum Problem

    Hi
    I am trying to create a enumerator for some Color items like this

    enum Colors : Color {

    yellowColor = Color.FromArgb( 254, 253, 21),

    YellowTopColor = Color.FromArgb( 254, 253, 21)

    };



    i get the followinng error message

    Type byte, sbyte, short, ushort, int, uint, long or ulong expected



    TIA



    Barry




  • Maqsood Ahmed

    #2
    Re: enum Problem

    Hello,
    Quoting MSDN:
    "An enumeration (enum) is a special form of value type, which inherits
    from System.Enum and supplies alternate names for the values of an
    underlying primitive type. An enumeration type has a name, an underlying
    type, and a set of fields. The underlying type must be one of the
    built-in signed or unsigned integer types (such as Byte, Int32, or
    UInt64). The fields are static literal fields, each of which represents
    a constant. The same value can be assigned to multiple fields. When this
    occurs, you must mark one of the values as the primary enumeration value
    for purposes of reflection and string conversion."
    So you can not define an enum of colors. You can use a struct for this
    purpose.

    HTH. Cheers.
    Maqsood Ahmed [MCP,C#]
    Kolachi Advanced Technologies


    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    Working...