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

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer at the bottom of the help menu, you will find… May 11, 2026 at 10:40 pm
  • Editorial Team
    Editorial Team added an answer Your client programmer is going to have to query the… May 11, 2026 at 10:40 pm
  • Editorial Team
    Editorial Team added an answer This is somewhat difficult to do in php, AFAIK. But… May 11, 2026 at 10:40 pm

Related Questions

I have a question regarding how to get the white- and black-listing feature of
Someone has already asked, How does the DiggBar work? in a previous question. While
I believe several of us have already worked on a project where not only
We are trying to build a Help Desk ticketing system just for intranet. Deciding

Trending Tags

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

Top Members

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.