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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:36:41+00:00 2026-06-18T00:36:41+00:00

I know I can pass a method like this: Class A: public void foo(Action<Class,

  • 0

I know I can pass a method like this:

Class A:
public void foo(Action<Class, Class, Class> bar)
{
    Class a;
    Class b;
    Class c;
    bar(a, b, c);
}
Class B:
public main()
{
    foo(bar);
}
protected void bar(Class a, Class b, Class c);

But I want it to be more conditional:

Class A:
public void foo(bar) {
    Class a;
    Class b;
    Class c;
    Class d;
    if(condition A)
        bar(a, b, c);
    else
        bar(a, b, c, d);
}
Class B:
public main()
{
    foo(bar);
}
protected void bar(Class a, Class b, Class c);
protected void bar(Class a, Class b, Class c, Class d);

How do I do this?

  • 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-18T00:36:42+00:00Added an answer on June 18, 2026 at 12:36 am

    There is no way of passing a method-group (a set of methods of the same name but with different signatures) except by-name as a string, and then using reflection. Any Delegate / Expression / MethodInfo representation must be to a single method.

    So: you cannot.


    Suggestion:

    interface IBar {
        void bar(Class a, Class b, Class c);
        void bar(Class a, Class b, Class c, Class d);
    }
    class YourType : IBar {
        void IBar.bar(Class a, Class b, Class c) {...}
        void IBar.bar(Class a, Class b, Class c, Class d) {...}
        ...
        public main()
        {
            foo(this);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a parent-child that defines some method .foo() like this: class Parent
So I have a class of overloaded methods like this: class Foo { public
I would like to know how can I pass a ruby variable inside an
I would like to know how I can do a low-pass filter in opencv
class Program { public delegate void VoidMethodDelegate(); public delegate int IntMethodDelegate(); static void Main(string[]
It's ridiculous I know... But heres a demo: class Foo { // A lot
My problem can be summed-up by this snippet: public interface TheClass<T> { public void
I have a class that looks like: class A { public: A(); void MethodThatWillNotBeInOtherStructure();
I know this seems pretty basic, and it should be, but I can't find
I know you can pass arguments through the RunWorkerAsync function call when you first

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.