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. class with dynamic property

class with dynamic property

Scheduled Pinned Locked Moved C#
question
3 Posts 3 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.
  • M Offline
    M Offline
    mehrdadc48
    wrote on last edited by
    #1

    Hi, How can I define a class that is enable to add properties dynamically to it?

    Best wishes

    A P 2 Replies Last reply
    0
    • M mehrdadc48

      Hi, How can I define a class that is enable to add properties dynamically to it?

      Best wishes

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      There could be someways to do this. Using an indexed property is an easy way to do this. Generics provides a way to do this as well[^]. Reflection could also be used for this too.

      The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

      1 Reply Last reply
      0
      • M mehrdadc48

        Hi, How can I define a class that is enable to add properties dynamically to it?

        Best wishes

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        The easy way to do this is to add a class that inherits from DynamicObject[^].

        Forgive your enemies - it messes with their heads

        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

        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