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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:22:43+00:00 2026-06-17T18:22:43+00:00

I have lots of functions, But I do need to run them inside another

  • 0

I have lots of functions, But I do need to run them inside another function.

I know I can do something like this

public void Method1()
{
bla bla
}


public void Method2()
{
bla bla
}

public void Wrapper(Action<string> myMethod)
        {
        method{
            myMethod()
              }
            bla bla
         }

And then call them using something like this:

wrapper(Method1());

The issue is tha sometimes I need to run Method1, and Method2, at the same time. They are a lot.
Sometimes One, sometimes several at the same time.

So I am thinking that would be great to do something like this:

Wrapper({bla bla bla; method(); bla bla; }
{
method{
bla bla bla;
 method();
 bla bla;

        }
}

Run a code block inside a method, and the parameter of the method is the code block.
Do you think is it possible or would you recommend another approach?

  • 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-17T18:22:44+00:00Added an answer on June 17, 2026 at 6:22 pm

    Having

    public static void Wrapper(Action<string> myMethod)
    {
        //...
    }
    

    you may specify myMethod using lambda expression:

    static void Main(string[] args)
    {
        Wrapper((s) =>
        {
            //actually whatever here
            int a;
            bool b;
            //..
            Method1();
            Method2();
            //and so on
        });
    }
    

    That is you don’t need to explicitly define a method with the desired signature (here matching Action<string>), but you may write inline lambda expression, doing whataever you need.

    From MSDN:

    By using lambda expressions, you can write local functions that can be
    passed as arguments or returned as the value of function calls.

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

Sidebar

Related Questions

I have lots of code like this in my constructors:- function __construct($params) { $this->property
I have lots of details. I want to stack them within an array, can
I have LOTS of logs and I need to compress them in a weekly
I have a Django my_forms.py like this: class CarSearchForm(forms.Form): # lots of fields like
I have done lots of reading up but I don’t understand why this is
I received a demand to correct a ASP website that have lots of functions
The problem is the following. We have lots of ajax call via $.ajax function.
I have a number of search functions (stored procedures) which need to return results
I have lots of functions and event handlers that are split across multiple javascript
Need your help on the below. I have a table where I have functions

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.