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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:56:38+00:00 2026-05-28T02:56:38+00:00

I have the following WPF code: public Window1() { InitializeComponent(); FlowDocument fd = new

  • 0

I have the following WPF code:

    public Window1()
    {
        InitializeComponent();
        FlowDocument fd = new FlowDocument();
        fd.LoadFromWordML("../../testdoc.docx");

FlowDocument (in System.Windows.Documents namespace) does not have a LoadFromWordML method. Rather this method is defined locally as follows:

    public static void LoadFromWordML(this FlowDocument doc, string path)

Yet as you can see, LoadFromWordML is being called as if it is a method of FlowDocument class, and in fact the ‘this’ argument is being suppressed.

What C# language facility allows this? (And a comment against language design: this makes it very difficult to read legacy code.)

  • 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-28T02:56:38+00:00Added an answer on May 28, 2026 at 2:56 am

    This is called extension methods

    Extension methods enable you to “add” methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods

    I have encountered these problems using them

    1. Hunting documentation to figure out where the hell they are defined.
    2. They cannot be defined to be virtual so it can lead to problems. In one of the projects I worked on we had Arc deriving from Circle. Somebody decided that Transform method should be an extension method. So most of the time it worked. Transforming a Circle yielded a transformed Circle and same with Arc. But it lead to subtle errors when you transformed an Arc when it was being used as an Circle reference.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have the following WPF code and it gives me an exception at TextBox
I have the following code that adds a background worker into a VB.net WPF
Have following code: public interface ITest { string St1 { get; } } public
I have the following sample code in WPF. It is working well when I
At the moment, I have the following code: Public tmr() As DispatcherTimer Public Sub
I'm new in WPF and I have the following problem. I have the following
I use C#, MVVM, WPF and Resharper. When using the following code: public bool
I have a DLL with the following code using System.Text; using Microsoft.Win32; using System.Diagnostics;
I have the following ControlTemplate for a WPF TabItem: <ControlTemplate x:Key=DefaultTabItemTemplate TargetType={x:Type TabItem}> <ControlTemplate.Resources>

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.