Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Dynamically ENUM

Dynamically ENUM

Scheduled Pinned Locked Moved C#
databasequestion
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lnmca
    wrote on last edited by
    #1

    Hi All, Is it possible to make the dynamically enum,means it should be created based on the values picked from DB? Thanks, Lalit

    N Z G P 4 Replies Last reply
    0
    • L lnmca

      Hi All, Is it possible to make the dynamically enum,means it should be created based on the values picked from DB? Thanks, Lalit

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Enums are compile time constants and can't be modified/created at run time.

      Navaneeth How to use google | Ask smart questions

      P 1 Reply Last reply
      0
      • L lnmca

        Hi All, Is it possible to make the dynamically enum,means it should be created based on the values picked from DB? Thanks, Lalit

        Z Offline
        Z Offline
        zlezj
        wrote on last edited by
        #3

        Try using T4 Look here[^] to get you started.

        1 Reply Last reply
        0
        • L lnmca

          Hi All, Is it possible to make the dynamically enum,means it should be created based on the values picked from DB? Thanks, Lalit

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Not in a way that it would be any useful. I think that you should look into how you could use a Dictionary instead.

          Despite everything, the person most likely to be fooling you next is yourself.

          1 Reply Last reply
          0
          • L lnmca

            Hi All, Is it possible to make the dynamically enum,means it should be created based on the values picked from DB? Thanks, Lalit

            P Offline
            P Offline
            Paulo Zemek
            wrote on last edited by
            #5

            You can always compile an unit using CodeDOM, but I doubt it will be any useful, as it will not have any hard-coded references to it. I also suggest using dictionaries to do the job.

            1 Reply Last reply
            0
            • N N a v a n e e t h

              Enums are compile time constants and can't be modified/created at run time.

              Navaneeth How to use google | Ask smart questions

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Appartently they can be created at run time, but they'd be fairly useless as far as I can tell.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups