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

  • SEARCH
  • Home
  • 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 6061291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:55:18+00:00 2026-05-23T08:55:18+00:00

Let say, I have a MulticastDelegate that implements generic delegate and contains several calls:

  • 0

Let say, I have a MulticastDelegate that implements generic delegate and contains several calls:

Func<int> func = null;
func += ( )=> return 8;
func += () => return 16;
func += () => return 32;

Now this code will return 32:

int x = func(); // x=32

I would like to know if there exists (or better I should ask why it doesn’t exist!) the C# language feature using which is possible to get the access to results of all delegate’s invocations, that means to get the list ({8,16,32})?

Of course it’s possible to do the same using .NET framework routines. Something like this will do the work:

public static List<TOut> InvokeToList<TOut>(this Func<TOut> func)
{
    var returnValue = new List<TOut>();
    if (func != null)
    {
        var invocations = func.GetInvocationList();
        returnValue.AddRange(invocations.Select(@delegate => ((Func<TOut>) @delegate)()));
    }
    return returnValue;
}

But I can’t get out from the system that there should be the better way, at least without casting (really, why MulticastDelegate is not generic when delegates are)?

  • 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-23T08:55:18+00:00Added an answer on May 23, 2026 at 8:55 am

    You can accomplish what you want if you don’t use a Func<int>, but an Action which takes a method as parameter which processes the return values. Here is a small example:

        static Action<Action<int>> OnMyEvent=null;
    
        static void Main(string[] args)
        {
            OnMyEvent += processResult => processResult(8);
            OnMyEvent += processResult => processResult(16);
            OnMyEvent += processResult => processResult(32);
    
            var results = new List<int>();
            OnMyEvent(val => results.Add(val));
    
            foreach (var v in results)
                Console.WriteLine(v);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I have a request table, that looks as follows: RequestId INT ReferenceNumber
Let say I have a file that contains a serialized object by BinaryFomatter. Now
Let say I have are two WPF forms: Form1 and Form2 . Form1 contains
Let say I have a multi-dimensional array like int a[10][10] int b[10][10] void arrayCopy(int*
Let say I have table Payments Id int autoincement Status int and my query
Let say i have one asp.net application that is having some page that uses
Let say I have IEnumerable<int> list = new int[] { 1, 2, 3 };
Let say I have 2 controls in a usercontrol : One (controlA) that have
let say we have class Person($name), Does $name need to be asigned as null
Let say you have any console application that is easily to start, later when

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.