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 7000585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:41:27+00:00 2026-05-27T20:41:27+00:00

I want to ask, can you do something similar to this? Event += eventInstance;

  • 0

I want to ask, can you do something similar to this?

Event += eventInstance;

Event is a class

I want to do something similar to delegates:

Write write1 = new Write(() => Console.WriteLine("Write1"));
Write write2 = new Write(() => Console.WriteLine("Write2"));
Write write3 = new Write(() => Console.WriteLine("Write3"));

Write write = write1 + write2 + write3;
write();

Thanks.

  • 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-27T20:41:28+00:00Added an answer on May 27, 2026 at 8:41 pm

    Overload the + operator and combine the delegates. Something like this:

    public class Write
    {
        private readonly Action _act;
    
        public Write(Action act)
        {
            _act = act;
        }
    
        public void Invoke()
        {
            _act();
        }
    
        public static Write operator +(Write left, Write right)
        {
            //Do appropriate null-checking.
            var del = (Action)Delegate.Combine(left._act, right._act);
            return new Write(del);
        }
    }
    

    And using it like so:

    Write write1 = new Write(() => Console.WriteLine("Write1"));
    Write write2 = new Write(() => Console.WriteLine("Write2"));
    Write write3 = new Write(() => Console.WriteLine("Write3"));
    
    Write writeall = write1 + write2 + write3;
    writeall.Invoke();
    

    Will print

    Write1
    Write2
    Write3
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just want to ask anyone here can solve this problem? I want to create
i am sorry to ask again since i asked something similar to this earlier,
I want to ask how can someone read keystrokes while in a html page
want to ask user to input something but not want to wait forever. There
I'm wondering if anybody has run across something similar to this before. Some quick
I found something similar here: Where can I find standard BNF or YACC grammar
I'm building something similar to this - http://www.impressivewebs.com/demo-files/content-switcher/content-switcher.html I wondered if anyone had any
Just want to ask the gurus out there about this. I know that CSS
i want ask some question about asp.net mvc Is static constructor will init every
I want to ask how other programmers are producing Dynamic SQL strings for execution

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.