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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:51:46+00:00 2026-06-07T13:51:46+00:00

Say I have an interface that specifies two void methods with no parameters. How

  • 0

Say I have an interface that specifies two void methods with no parameters. How can I “plug” two System.Action(T) methods in some class that implements the interface? In my example below, this would be in the void PushFoo(Action bar1, Action bar2) method:

public interface IFoo
{
    void Bar1();
    void Bar2();
}

public class Bla
{
    Stack<IFoo> _fooStack = new Stack<IFoo>();

    public void PushFoo(IFoo foo)
    {
        _fooStack.Push(foo);
    }

    public void PushFoo(Action bar1, Action bar2)
    {
        IFoo foo = null;

        // assign bar1 and bar2 to foo
        //foo = ... ;

        _fooStack.Push(foo);
    }
}
  • 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-06-07T13:51:47+00:00Added an answer on June 7, 2026 at 1:51 pm
    public Class ActionableFoo : IFoo
    {
        Action _bar1, _bar2;
    
        public ActionableFoo(Action b1, Action b2)
        {
            _bar1 = b1;
            _bar2 = b2;
        }
    
        public void Bar1() { if(_bar1 != null) _bar1(); }
        public void Bar2() { if(_bar2 != null) _bar2(); }
    }
    

    Then , in your example:

    public void PushFoo(Action bar1, Action bar2)
    {
        IFoo foo = new ActionableFoo(bar1, bar2);
        _fooStack.Push(foo);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have interface window_creator that responsible for creation of windows. For simplicity
Say I have my class @interface Person : NSObject { NSString *name; } I
Say I have a parent interface/class like so interface Parent<T> {} And a number
Lets say I have two interfaces interface A and interface B: public interface A
Say we have an overlay DHTML panel on a web page that contains two
Let's say I have two constructors in my class: public User (List<Source1> source){ ...
Just for learn: Say we have: interface Musician { /* content skipped */ }
Let's say I have remote interface A: @Remote public interface A { public Response
To keep things simplified lets say I have an interface RandomProvider interface public interface
Say I have this code - public interface ParentInterface1 { public List<? extends ChildInterface1>

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.