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
T

TheLastBastion

@TheLastBastion
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Obtaining Caller of a Method in C#
    T TheLastBastion

    I was wondering if there is any (preferably relatively straighforward) way for a method in C# to obtain the object which made the call. For example...

    namespace Example
    {
    public class A
    {

      private B b;
    
      public A()
      {
         b = new B();
         b.Call();
      }
    

    }

    public class B
    {
    public B()
    {
    }

      public void Call()
      {
        //So, who called this function?
        object caller = null;   // Replace null with what so that
                                // we get the instance of A making
                                // the call.
      }
    

    }

    }

    I hope this makes some sense. Any hints / tips are much appreciated. -- The Last Bastion

    C# csharp tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups