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. Current Function/Property Name Using Reflection

Current Function/Property Name Using Reflection

Scheduled Pinned Locked Moved C#
question
5 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.
  • S Offline
    S Offline
    Shajeel
    wrote on last edited by
    #1

    Hi Is it possible to get the current function or property name using reflection? If it is then how?

    Regards Shajeel

    R 1 Reply Last reply
    0
    • S Shajeel

      Hi Is it possible to get the current function or property name using reflection? If it is then how?

      Regards Shajeel

      R Offline
      R Offline
      Roger Alsing 0
      wrote on last edited by
      #2

      string name = System.Reflection.MethodBase.GetCurrentMethod ().Name;

      My Blog

      S 1 Reply Last reply
      0
      • R Roger Alsing 0

        string name = System.Reflection.MethodBase.GetCurrentMethod ().Name;

        My Blog

        S Offline
        S Offline
        Shajeel
        wrote on last edited by
        #3

        any thing similar for property?

        Regards Shajeel

        R 1 Reply Last reply
        0
        • S Shajeel

          any thing similar for property?

          Regards Shajeel

          R Offline
          R Offline
          Roger Alsing 0
          wrote on last edited by
          #4

          Its the same.. Properties are methods in IL code. However , you will have to remove "set_" and "get_" prefixes that are applied to property methods. eg if you have a property called "Foo" and you use the code I supplied in the "setter" you will get "set_Foo" and in the getter you will get "get_Foo"

          My Blog

          S 1 Reply Last reply
          0
          • R Roger Alsing 0

            Its the same.. Properties are methods in IL code. However , you will have to remove "set_" and "get_" prefixes that are applied to property methods. eg if you have a property called "Foo" and you use the code I supplied in the "setter" you will get "set_Foo" and in the getter you will get "get_Foo"

            My Blog

            S Offline
            S Offline
            Shajeel
            wrote on last edited by
            #5

            thanx

            Regards Shajeel

            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