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. Calling identically named properties

Calling identically named properties

Scheduled Pinned Locked Moved C#
question
4 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
    MartinSmith
    wrote on last edited by
    #1

    RadioButtonList and CheckBoxList both share certain common properties (e.g. RepeatColumns RepeatDirection RepeatLayout ) However these properties are not inherited from a common ancestor. Is there any neat way I can have 1 common function accepting either a RadioButtonList or CheckBoxList and use these properties within the function method without having to check the type and then casting to 1 or the other?

    D W 2 Replies Last reply
    0
    • M MartinSmith

      RadioButtonList and CheckBoxList both share certain common properties (e.g. RepeatColumns RepeatDirection RepeatLayout ) However these properties are not inherited from a common ancestor. Is there any neat way I can have 1 common function accepting either a RadioButtonList or CheckBoxList and use these properties within the function method without having to check the type and then casting to 1 or the other?

      D Offline
      D Offline
      Dustin Metzgar
      wrote on last edited by
      #2

      You could do it with reflection. But that's about it.

      1 Reply Last reply
      0
      • M MartinSmith

        RadioButtonList and CheckBoxList both share certain common properties (e.g. RepeatColumns RepeatDirection RepeatLayout ) However these properties are not inherited from a common ancestor. Is there any neat way I can have 1 common function accepting either a RadioButtonList or CheckBoxList and use these properties within the function method without having to check the type and then casting to 1 or the other?

        W Offline
        W Offline
        Wjousts
        wrote on last edited by
        #3

        You could create your own class which wraps either a RadioButtonList or a CheckBoxList and exposes those common properties. It still wouldn't be an entirely statisfactory solution, but at least it would hide all the messy type checking and casting.

        M 1 Reply Last reply
        0
        • W Wjousts

          You could create your own class which wraps either a RadioButtonList or a CheckBoxList and exposes those common properties. It still wouldn't be an entirely statisfactory solution, but at least it would hide all the messy type checking and casting.

          M Offline
          M Offline
          MartinSmith
          wrote on last edited by
          #4

          Thanks for the responses. I was just checking that I wasn't missing something obvious. Cheers. Martin

          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