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. Accessing class properties using foreach or any iteration method

Accessing class properties using foreach or any iteration method

Scheduled Pinned Locked Moved C#
algorithmshelpquestion
4 Posts 4 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.
  • V Offline
    V Offline
    venugopalachary
    wrote on last edited by
    #1

    Hi, I have a class 'C1' with lot of properties with different retun type, and those are set using another class's method 'C2.m1'. i am searching for a technic to get those values using iteration mathod and display in a datagrid, Instead of directly accessing those properties like 'C1.property1'. Could you one please help me..? Thank you Venu.

    B L M 3 Replies Last reply
    0
    • V venugopalachary

      Hi, I have a class 'C1' with lot of properties with different retun type, and those are set using another class's method 'C2.m1'. i am searching for a technic to get those values using iteration mathod and display in a datagrid, Instead of directly accessing those properties like 'C1.property1'. Could you one please help me..? Thank you Venu.

      B Offline
      B Offline
      Berlus
      wrote on last edited by
      #2

      Seemed like a prefect case for using "Reflection". Try seraching "get property by reflection c#" berlus

      1 Reply Last reply
      0
      • V venugopalachary

        Hi, I have a class 'C1' with lot of properties with different retun type, and those are set using another class's method 'C2.m1'. i am searching for a technic to get those values using iteration mathod and display in a datagrid, Instead of directly accessing those properties like 'C1.property1'. Could you one please help me..? Thank you Venu.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Sounds like you want a PropertyGrid then. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.

        1 Reply Last reply
        0
        • V venugopalachary

          Hi, I have a class 'C1' with lot of properties with different retun type, and those are set using another class's method 'C2.m1'. i am searching for a technic to get those values using iteration mathod and display in a datagrid, Instead of directly accessing those properties like 'C1.property1'. Could you one please help me..? Thank you Venu.

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

          Well a DataGridView control does reflection automatically. If you have a collection of 'C1' objects that implements the IList interface, then any public property will automatically be extracted and used to populate the cells in the apropriate column. Does this help? Harry.

          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