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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:07:27+00:00 2026-06-06T03:07:27+00:00

I would imagine this might use Reflection.Emit, but a similar question on SO only

  • 0

I would imagine this might use Reflection.Emit,

but a similar question on SO only answers how to create a class/method dynamically, not how to update an existing class.

In a similar vein, is it possible to delete methods / classes at runtime? If so, I suppose one could just delete the class, and add it back with its old methods plus the new one.

Thanks in advance.

P.S. I don’t have an intended use for this, it is merely a matter of curiosity.

  • 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-06-06T03:07:28+00:00Added an answer on June 6, 2026 at 3:07 am

    In regular C# / .NET, the answer is a simple “no”. The most you can do is write a DynamicMethod which can behave like a method of that type (access to private fields etc), but it won’t ever be on the API – you just end up with a delegate.

    If you use dynamic, you can do pretty much anything you want. You can emulate that with ExpandoObject by attaching delegates in place of methods, but on a custom dynamic type you can do most anything – but this only impacts callers who use the dynamic API. For a basic ExpandoObject example:

    dynamic obj = new ExpandoObject();
    Func<int, int> func = x => 2*x;
    obj.Foo = func;
    int i = obj.Foo(123); // now you see it
    obj.Foo = null; // now you don't
    

    For properties and events (not methods), you can use the System.ComponentModel approach to change what appears at runtime, but that only impacts callers who get access via System.ComponentModel, which means mainly: UI data-binding. This is how DataTable represents columns as pseudo-properties (forgetting about “typed datasets” for the moment – it works without those).

    For completeness, I should also mention extension methods. Those are more a compiler trick, not a runtime trick – but kinda allow you to add methods to an existing type – for small values of “add”.

    One final trick, commonly used by ORMs etc – is to dynamically subclass the type, and provide additional functionality in the subclass. For example, overriding properties to intercept them (lazy-loading, etc).

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

Sidebar

Related Questions

This use case seems like it would apply to just about every form, but
Imagine you have a NB Platform application and you would like to use that
I imagine two, but I would like to confirm if I am making sense
This one has been puzzling my for some time now. Let's imagine a class
What language should I use for file and string manipulation? This might seem objective,
I suppose this question is a variation on a theme , but different. Torrents
imagine something like this: import class B.*; interface A supports A.testSum { int sum(
If there were such a thing I would imagine the syntax to be something
Does dependency injection potentially cause large overhead? I would imagine so, especially if the
Imagine a user that would like to put a form on their website that

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.