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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:19:36+00:00 2026-05-11T05:19:36+00:00

Can I dynamically create a function and invoke it (passing values into it) in

  • 0

Can I dynamically create a function and invoke it (passing values into it) in one line of code?

Clarification: I was looking for some way that could allow me to create an anonymous function and then calling it directly. Sort of:

delegate(string aa){ MessageBox.show(aa); }('Hello World!'); 

or something like that (I know the above code does not compile, but I wanted something close).

  • 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. 2026-05-11T05:19:37+00:00Added an answer on May 11, 2026 at 5:19 am
    new Action<int>(x => Console.WriteLine(x))(3); 

    it’s not so readable but answering your question, you definitely can.

    EDIT: just noticed you tagged it as c# 2.0, the answer above is for 3.5, for 2.0 it would be

    new Action<int>(delegate(int x) { Console.WriteLine(x); })(3); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how I can Dynamically create an installation package that installs files
How can I dynamically create a host name in ASP.NET? Like if people come
How can I dynamically create a view controller with a NIB file? Thanks.
How can I replace storyboard with XIB? While trying to create dynamically views and
Can we create a WEB GRID dynamically using JAVASCRIPT ? I am using MVC
Can we create a temporary table from the stored procedure results dynamically? I do
Can c++ create array of pointers to different classes dynamically loaded from dll? ps.without
How can I create a PagerView dynamically? Without using a xml? Let's say that
In the following example i can create an object dynamically via a string; however,
can someone please help me out? I'm trying to create an input dynamically with

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.