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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:50:41+00:00 2026-05-16T15:50:41+00:00

Why I’m unable to extend an abstract class. Is there any work around to

  • 0

Why I’m unable to extend an abstract class. Is there any work around to achieve this?

In silverlight, Enum.GetNames is missing. So, I would like to extend it and have it in my utility assembly. By then, got into this.

  • 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-16T15:50:42+00:00Added an answer on May 16, 2026 at 3:50 pm

    The problem here is not that you can’t add an extension method to an abstract class (you can – you can add an extension method to any type) – it’s that you can’t add a static method to a type with extension methods.

    Extension methods are static methods that present themselves in C# as instance methods. But they’re still static. Adding a static method to a type requires the ability to redefine the type, which you can only do if you have the source code 🙂

    Best bet, if you want this method, is to write your own static and see if you can perhaps rip the code out of reflector.

    However, it’s entirely possible that it’s not there because it’s physically not supported in Silverlight (I don’t know – I haven’t investigate)

    EDIT

    Following on from your comment – and I hope that I’ve understood you here – I think what you want to be able to do is something like this (targetting object to prove the point):

    public static class ExtraObjectStatics
    {
      public static void NewStaticMethod()
      {
    
      }
    }
    
    public class Test
    {
      public void foo()
      {
        //You can't do this - the static method doesn't reside in the type 'object'
        object.NewStaticMethod();
        //You can, of course, do this
        ExtraObjectStatics.NewStaticMethod();
      }
    }
    

    If you think about it – of course you can’t inject new static methods into an existing type because, like I said in paragraph two, you have to be able to recompile the underlying type; and there simply is no way around that.

    What you can do is (and I don’t actually recommend this – but it’s an option) create yourself a new type called Enum and place it inside a new namespace:

    namespace MySystem
    {
      public class Enum
      {
        public static string[] GetNames()
        {
          //don't actually know how you're going to implement it :)
        }
      }
    }
    

    And now – when you want to use it, what you can’t do is this:

    using System;
    using MySystem;
    
    namespace MyCode
    {
      public class TestClass
      {
        public static void Test()
        {
          Enum.GetNames(); //error: ambiguous between System and MySystem
        }
      }
    }
    

    Because the using in the outermost scope to both ‘System’ and ‘MySystem’ will cause the compiler not to be able to resolve the correct Enum type.

    What you can do, however, is this:

    using System;
    
    namespace MyCode
    {
      using MySystem; //move using to inside the namespace
      public class TestClass
      {
        public static void Test()
        {
          //will now work, and will target the 'MySystem.Enum.GetNames()'
          //method.
          Enum.GetNames();
        }
      }
    }
    

    Now, code within that namespace (within that file only) will always resolve Enum to the one in your namespace because that’s the nearest using directive in terms of scope.

    So, you can think of this as overriding the whole Enum type for the benefit of a given namespace that includes a using MySystem; in it.

    But, it does exactly that – it replaces the existing System.Enum with MySystem.Enum – meaning that you lose all the members of the System.Enum type.

    You could get around this by writing wrapper methods in your Enum type around the System.Enum versions – making sure that you fully-qualify the type as System.Enum.

    Having looked at the implementation of the GetNames method in Reflector – it relies on internal data that I don’t think you’re going to be able to build… but I would be very interested to hear if you are actually able to reproduce the method in Silverlight.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.