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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:13:08+00:00 2026-05-11T18:13:08+00:00

This question already has an answer here: What are Extension Methods? 5 answers Usage

  • 0

This question already has an answer here:
What are Extension Methods? 5 answers
Usage of Extension Methods 9 answers
What Advantages of Extension Methods have you found? [closed] 30 answers

So I run into the term “extension-methods” frequently, when reading about .Net and intellisensing (!) around…

What are extension-methods — and what sets them apart from other methods?

  • 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-11T18:13:08+00:00Added an answer on May 11, 2026 at 6:13 pm

    They’re static methods that can be added to other types without modifying the original type.

    For example, say you want to be able to call ToInt() on a string. You can create a method like this:

    public static int ToInt( this string value ){ return Int32.Parse( value ); }
    

    Now say you have a TextBox called Port on your web page you can get it as an int like this:

    int port = Port.Text.ToInt();
    

    Real world use of extension methods is usually much more useful then that and is used heavily by Fluent APIs and testing frameworks.

    UPDATE: Another good use of extensions is to provide base class like default behaviors for interfaces. Many popular testing methodologies depend on interface definitions and the ability to mock those interfaces. Unfortunately, basing everything on interfaces however loses some of the benefits of inheritance. Extension methods can add some of the convenience of base classes without the pollution of the interfaces.

    For example say I have a Window base class defined like this

    public class Window
    {
        public void Show( object owner ){...}
        public void Show(){ Show( null ); }
    }
    

    Now I want to extract an IWindow interface from this class. I don’t really want to require every object that derives from IWindow to have to implement the second Show method since it’s just a basic overload. So I can define my interface like this:

    public interface IWindow
    {
        void Show( object owner );
    }
    

    And an extension method like this:

    public static void Show( this IWindow window )
    {
        window.Show( null );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question already has an answer here: How do I enumerate an enum in
This question has already an answer here: How do you clear your MRU list
This question to which I already found the answer is posted here in case
Python beginner here, so I apologize if this question has a simple answer. (I
If this question has already been asked I appologies, please point me in the
Preamble So, this question has already been answered, but as it was my first
I already know the obvious answer to this question: just download <insert favorite windows
Question: I have a question that is apparently not answered by this already-asked Bash
Update: I can't delete this question, because the answer has been upvoted, yet it
We've had this question already, but I want to narrow it down to already

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.