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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:20:00+00:00 2026-05-29T23:20:00+00:00

Why Extension methods do not use implicit conversions but static methods do? Can anybody

  • 0

Why Extension methods do not use implicit conversions but static methods do? Can anybody explain with a proper example?

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-29T23:20:01+00:00Added an answer on May 29, 2026 at 11:20 pm

    Because the C# spec states:

    An extension method Ci.Mj is eligible if:

    · Ci is a non-generic, non-nested class

    · The name of Mj is identifier

    · Mj is accessible and applicable when applied to the
    arguments as a static method as shown above

    · An implicit identity, reference or boxing conversion exists
    from expr to the type of the first parameter of Mj.

    As far as the C# spec is concerned, a user-defined conversion operator is different than an implicit reference conversion, and certainly different than an identity or boxing conversion.

    For a hint on why:

    public static class Extensions
    {
        public static void DoSomething(this Bar b)
        {
            Console.Out.WriteLine("Some bar");
        }
    
        public static void DoSomething(this Boo b)
        {
            Console.Out.WriteLine("Some boo");
        }
    }
    
    public class Foo
    {
        public static implicit operator Bar(Foo f)
        {
            return new Bar();
        }
        public static implicit operator Boo(Foo f)
        {
            return new Boo();
        }
    }
    
    public class Bar { }
    public class Boo { }
    
    public class Application
    {
        private Foo f;
        public void DoWork()
        {
            // What would you expect to happen here?
            f.DoSomething();
    
            // Incidentally, this doesn't compile either:
            Extensions.DoSomething(f);
        }
    }
    

    C# could not unambiguously choose which implicit conversion to execute.

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

Sidebar

Related Questions

This may be an ignorant question, but I'm unsure why I can not use
I typically use extension methods very sparingly. When I do feel compelled to write
How to use extension methods to form the second query as the first one.
I have a few 'helper' style extension methods I use quite regularly now (they
As I understand it when I use LINQ extension methods (with lambda expression syntax)
how are extension methods evaluated? or in a very specific use case: if an
I have a set of extension methods that I regularly use for various UI
As an example, I have an several extension methods for converting strings and objects
Extension methods are not good for testing (that's described here: Mocking Extension Methods with
The CollectionViewSource.GetDefaultView() method is not in Silverlight 3. In WPF I have this extension

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.