Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1102683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:13:26+00:00 2026-05-17T01:13:26+00:00

I have an event Load public delegate void OnLoad(int i); public event OnLoad Load;

  • 0

I have an event Load

public delegate void OnLoad(int i);
public event OnLoad Load;

I subscribe to it with a method:

public void Go()
{
    Load += (x) => { };
}

Is it possible to retrieve this method using reflection? How?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:13:27+00:00Added an answer on May 17, 2026 at 1:13 am

    In this particular case you could, with reflection. However, in general, you can’t. Events encapsulate the idea of subscribers subscribing and unsubscribing – and that’s all. A subscriber isn’t meant to find out what other subscribers there are.

    A field-like event as you’ve just shown is simply backed by a field of the relevant delegate type, with autogenerated add/remove handlers which just use the field. However, there’s nothing to say they have to be implemented like that. For example, an event can store its subscribers in an EventHandlerList, which is efficient if you have several events in a class and only a few of them are likely to be subscribed to.

    Now I suppose you could try to find the body of the “add” handler, decompile it and work out how the event handlers are being stored, and fetch them that way… but please don’t. You’re creating a lot of work, just to break encapsulation. Just redesign your code so that you don’t need to do this.

    EDIT: I’ve been assuming that you’re talking about getting the subscribers from outside the class declaring the event. If you’re inside the class declaring the event, then it’s easy, because you know how the event is being stored.

    At that point, the problem goes from “fetching the subscribers of an event” to “fetching the individual delegates making up a multicast delegate” – and that’s easy. As others have said, you can call Delegate.GetInvocationList to get an array of delegates… and then use the Delegate.Method property to get the method that that particular delegate targets.

    Now, let’s look again at your subscription code:

    public void Go()
    {
        Load += (x) => { };
    }
    

    The method that’s used to create the delegate here isn’t Go… it’s a method created by the C# compiler. It will have an “unspeakable name” (usually with angle brackets) so will look something like this:

    [CompilerGenerated]
    private static void <Go>b__0(int x)
    {
    }
    

    Now, is that actually what you want to retrieve? Or were you really looking to find out which method performed the subscription, rather than which method was used as the subscribed handler?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.