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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:37:37+00:00 2026-05-15T20:37:37+00:00

So at work I was using an API that we didn’t write, and one

  • 0

So at work I was using an API that we didn’t write, and one of the methods took a delegate. For one reason or another, the idea came to me that I have an extension method that fits that signature, so I was wondering if it would work. I was sure it wouldn’t but much to my surprise, it did. Allow me to demonstrate:

Say I have these classes:

public interface IMyInterface
{

}

public class MyClass : IMyInterface 
{ 

}

public static class Extensions
{
    public static string FuncMethod(this IMyInterface imy, int x)
    {
        return x.ToString();
    }
}

Now let’s say I have a method signature somewhere that looks like this:

    private static void Method(Func<int, string> func)
    {

    }

Now my extension method (looks like it) matches that signature, but we all know that extension methods are just smoke and mirrors, so it really doesn’t match that signature. Yet, I can safely do this:

var instance = new MyClass();
Method(instance.FuncMethod);

My question is, how does this work? What does the compiler generate for me to make this acceptable. The actual signature of the Extension method takes an instance of IMyInterface, but the Func doesn’t so what’s happening here for me behind the scenes?

  • 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-15T20:37:38+00:00Added an answer on May 15, 2026 at 8:37 pm

    Instance methods are implemented as taking hidden this parameter.

    When you create an instance delegate from an extension method, the hidden this parameter is passed to the method as the first normal parameter.

    Note that this cannot be done with value types.

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you considered using a Line Border within the JPanel.… May 16, 2026 at 5:52 pm
  • Editorial Team
    Editorial Team added an answer i think that this test sample can help you string… May 16, 2026 at 5:52 pm
  • Editorial Team
    Editorial Team added an answer Just create a BEFORE INSERT trigger: CREATE TRIGGER your_trigger_name FOR… May 16, 2026 at 5:52 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm using an API that requires me to pass a function pointer as a
I want to execute stored procedure with one parameter that returns table using EF4
I'm creating a C api that hides some functionality in a DLL file. Since
I'm working on a GWT app that's using Google Maps. I'm trying to add
I'm trying to write a class that can add a bookmark to my Delicious
I am using the eBay JavaScript Finding API. The currency id member of the
I have the same problem as described in the posts listed below. That is,
I have been writing a program that watches a directory and when files are
I'm using the following code to capture a screenshot of the selected tab chrome.tabs.captureVisibleTab(
When adding a work item to TFS 2010 via the SDK, the incidents are

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.