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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:21:11+00:00 2026-05-26T11:21:11+00:00

static void Main() { Action<string> myAction = SomeMethod; myAction(Hello World); myAction.Invoke(Hello World); } static

  • 0
static void Main()
{
    Action<string> myAction = SomeMethod;

    myAction("Hello World");
    myAction.Invoke("Hello World");
}

static void SomeMethod(string someString)
{
    Console.WriteLine(someString);
}

The output for the above is:

Hello World
Hello World

Now my question(s) is

  • What is the difference between the two ways to call the Action, if any?

  • Is one better than the other?

  • When use which?

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-26T11:21:11+00:00Added an answer on May 26, 2026 at 11:21 am

    All delegate types have a compiler-generated Invoke method.
    C# allows you to call the delegate itself as a shortcut to calling this method.

    They both compile to the same IL:

    C#:

    Action<string> x = Console.WriteLine;
    x("1");
    x.Invoke("2");
    

    IL:

    IL_0000:  ldnull      
    IL_0001:  ldftn       System.Console.WriteLine
    IL_0007:  newobj      System.Action<System.String>..ctor
    IL_000C:  stloc.0     
    IL_000D:  ldloc.0     
    IL_000E:  ldstr       "1"
    IL_0013:  callvirt    System.Action<System.String>.Invoke
    IL_0018:  ldloc.0     
    IL_0019:  ldstr       "2"
    IL_001E:  callvirt    System.Action<System.String>.Invoke
    

    (The ldnull is for the target parameter in an open delegate)

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

Sidebar

Related Questions

public static void Main(string[] args) { Action a = () => Console.WriteLine(MethodInfo.GetCurrentMethod().Name); a(); }
static void Main() { string str; str = Console.ReadLine(); while (str != null)//HERE! {
static void Main(string[] args) { //read in the file StreamReader convert = new StreamReader(../../convert.txt);
public static void main(String[] args) { List<? extends Object> mylist = new ArrayList<Object>(); mylist.add(Java);
public class Test { public static void main(String[] args) { } } class Outer
public class doublePrecision { public static void main(String[] args) { double total = 0;
public class WrapperTest { public static void main(String[] args) { Integer i = 100;
This code compiles: private static void Main(string[] args) { bool? fred = true; if
class Program { static void Main(string[] args) { String value = Two; Type enumType
public class Main3 { public static void main(String[] args) { Integer min = Integer.MIN_VALUE;

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.