0

I have this enum function with some elements:

public enum TrackingTypeEnum
{
    None,
    Start,
    PageView,
    Foreground,
    Background,
    Push,
}

And I want to add some elements there, but not manually in the function, i want to use "new" command but dosn't work.

I've tried this:

TrackingTypeEnum Custom = new TrackingTypeEnum;

Any solution?

Thanks!

Javi
  • 17
  • 4

2 Answers2

1

According to official documentation, you can't use enum keywork in such a way. In sort, an enum is a list of constants you can assign values to.

Read: http://msdn.microsoft.com/en-us/library/sbbt4032.aspx

fillobotto
  • 3,698
  • 5
  • 34
  • 58
-1

That's not what enums are for- you should only use them to store every possible state of an object. If you really do want to use enums, you can store those additional values in a dictionary, like it's covered in this SO answer:

C#: can you add to an enum type in run-time

Community
  • 1
  • 1
Michał Żołnieruk
  • 2,095
  • 12
  • 20