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

  • Home
  • SEARCH
  • 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 464863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:19:06+00:00 2026-05-12T23:19:06+00:00

This is a terminology question. In C#, I can do this: delegate Stream StreamOpenerDelegate(String

  • 0

This is a terminology question. In C#, I can do this:

delegate Stream StreamOpenerDelegate(String name);

void WorkMethod(StreamOpenerDelegate d)
{
    // ...
}

void Exec1()
{
    WorkMethod((x) =>
        {
            return File.OpenRead(x);
        });
}

void Exec2()
{
    StreamOpenerDelegate opener = (x) =>
        {
            return File.OpenRead(x);
        };

    WorkMethod(opener);
}

Q1
The Exec1() method demonstrates the use of an anonymous delegate, correct?

Q2
Inside Exec2(), would opener
be considered an anonymous delegate? It does have a name. If it’s not an anonymous delegate, what should I call it? Is there a name for this syntax? “named anonymous delegate?” a local variable holding an anonymous delegate?

  • 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-12T23:19:06+00:00Added an answer on May 12, 2026 at 11:19 pm

    Q1: There’s no such term as “anonymous delegate” (in the C# language specification) – but this uses a lambda expression which is one kind of anonymous function. See section 7.14 of the C# language specification for details.

    Q2: opener is a variable. The variable is assigned a value created using a lambda expression. After it’s been created, the delegate is just an instance of StreamOpenerDelegate. In other words, the concepts of lambda expression, anonymous function and anonymous method are source code concepts rather than execution time concepts. The CLR doesn’t care how you created the delegate.

    By the way, both of your lambda expressions can be expressed more concisely – fewer parentheses etc:

    void Exec1()
    {
        WorkMethod(x => File.OpenRead(x));
    }
    
    void Exec2()
    {
        StreamOpenerDelegate opener = x => File.OpenRead(x);
        WorkMethod(opener);
    }
    

    alternatively you could just use a method group conversion:

    StreamOpenerDelegate opener = File.OpenRead;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just can't remember the terminology used for this and other related properties. EDIT
Apologies if I've got the terminology wrong here—I can't think what this particular idiom
I'm pretty sure I've seen this somewhere, but I can't find the right terminology
Please Note: This question is about the difference in terminology between the words destructor
I'm trying to name an object that can be a file or a directory.
This is a basic question but I can't find an answer. I've looked into
Forgive my probably incorrect application of terminology in this question (btw, please correct me
So I'm a little confused by this terminology. Everyone refers to Asynchronous computing as
I'm not sure what kind of terminology to use in this so please edit
This is a bit of a long shot, but if anyone can figure it

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.