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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:59:34+00:00 2026-05-20T04:59:34+00:00

Here’s a simple code, where I try to implement some sort of polymorphysm. You

  • 0

Here’s a simple code, where I try to implement some sort of polymorphysm.

You can see overloaded Invoker function, accepting Func<T,R> and Action<T> as an argument.

Compiler says it couldn’t be compiled because of ambiguity if Invoker methods:

class Program
{
    static void Invoker(Action<XDocument> parser)
    {
    }

    static void Invoker(Func<XDocument,string> parser)
    {
    }

    static void Main(string[] args)
    {
        Invoker(Action);
        Invoker(Function);
    }

    static void Action(XDocument x)
    {
    }

    static string Function(XDocument x)
    {
        return "";
    }
}

I get 3(!) errors, and none of it i can explain. Here they are:

Error 1 The call is ambiguous between the following methods or properties: ‘ConsoleApplication3.Program.Invoker(System.Action)’ and ‘ConsoleApplication3.Program.Invoker(System.Func)’ c:\users\i.smagin\documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs 21 4 ConsoleApplication3

Error 2 The call is ambiguous between the following methods or properties: ‘ConsoleApplication3.Program.Invoker(System.Action)’ and ‘ConsoleApplication3.Program.Invoker(System.Func)’ c:\users\i.smagin\documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs 22 4 ConsoleApplication3

Error 3 ‘string ConsoleApplication3.Program.Function(System.Xml.Linq.XDocument)’ has the wrong return type c:\users\i.smagin\documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs 22 12 ConsoleApplication3

Any ideas?

  • 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-20T04:59:35+00:00Added an answer on May 20, 2026 at 4:59 am

    Both

    static void Action(XDocument x)
    

    and

    static string Function(XDocument x)
    

    have same method signature.

    Return value is not part of method signature. So, just having a different return type won’t work. They must have different number of parameters or parameter types must be different.

    Since, compiler cannot figure out which one (method that takes Action or method that takes Func) to use, you have to explicitly specify it:

    Invoker(new Action<XDocument>(Action));
    Invoker(new Func<XDocument, String>(Function));
    

    to resolve ambiguity.

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

Sidebar

Related Questions

Here a simple question : What do you think of code which use try
Here's some of my production code (I had to force line breaks): task =
Here is my javascript code for a cursor focus function to go to username
Here is my code sample, let me know if it can be further improved?
here are 2 screen shots when i try to debug my code in visual
Here is some code I made :) @echo off set source=R:\Contracts\ set destination=R:\Contracts\Sites\ ROBOCOPY
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here's an interesting problem. Is there a way to write some code using LINQ
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see

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.