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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:03:44+00:00 2026-06-04T17:03:44+00:00

I need to change some basic calculations during the life-time of an object. I

  • 0

I need to change some basic calculations during the life-time of an object.

I know how to create a dynamic method and call it through delegate.Invoke; however it is twice as costly as a static method call.

Is it possible to emit CIL inside an existing method?

Say one method calls another and the another can have different body (one at a time):

public void Worker()
{
    while(true)
    {
        int a = queueA.Dequeue();
        int b = queueB.Dequeue();

        int c = Calculate(a,b);
    }
}

int Calculate(int a, int b)
{
    // here goes dynamic code.
    // could be return a - b;
    // could be return b - a;
}

Please note that the calculation logic in the example is greatly simplified.

  • 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-04T17:03:46+00:00Added an answer on June 4, 2026 at 5:03 pm

    Once a class is compiled you can no longer change its IL. You can emit entire new methods dynamically at runtime using Reflection.Emit. But you cannot modify existing ones.

    If you need the speed of static method calls you might consider different approaches that OOP offer for example.

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

Sidebar

Related Questions

I need to know when a sharer has been authorized (to change some UI)
I only know a few basic things in JavaScript, so I need some help
I need to change some text values inside an after effect project file that
I need to change some custom properties values in many files. Here is an
I'm using itextsharp to generate the PDFs, but I need to change some text
I have some images that need to change, based not only on hover, but
I've got some UITableViewCells that need to change their height depending on the length
I need a function to change the appearance of some elements in my HTML
How to change HTML background with JavaScript Function? I need some simple function to
Here's some background. I hope someone has some ideas. I know some basic jQuery

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.