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. Extensions Property

Extensions Property

Scheduled Pinned Locked Moved C#
question
4 Posts 2 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.
  • R Offline
    R Offline
    reza assar
    wrote on last edited by
    #1

    hi all i want to Extend a Property for a class is there some thing like Extension Methods for properties?

    D 1 Reply Last reply
    0
    • R reza assar

      hi all i want to Extend a Property for a class is there some thing like Extension Methods for properties?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Extension methods only work at the class level. Depending on what you want to do, you may have a couple of options. You'll either have to inherit from the class and override the property or add another property and call the base class property from it.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      R 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Extension methods only work at the class level. Depending on what you want to do, you may have a couple of options. You'll either have to inherit from the class and override the property or add another property and call the base class property from it.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        R Offline
        R Offline
        reza assar
        wrote on last edited by
        #3

        i know bun unfortunately i can`t derive from desired class because it force me to change all of the project . in addition i am looking for a better solution

        D 1 Reply Last reply
        0
        • R reza assar

          i know bun unfortunately i can`t derive from desired class because it force me to change all of the project . in addition i am looking for a better solution

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          reza assar wrote:

          i know bun unfortunately i can`t derive from desired class because it force me to change all of the project

          Sounds like the requirements and specs changed after development started. You really have to plan ahread for these things.

          reza assar wrote:

          in addition i am looking for a better solution

          You don't have one. Extension methods cannot be attached to a property of a type, only to the type itself.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          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