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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:58:18+00:00 2026-05-27T09:58:18+00:00

the C# call Math.Pow(2,3); in ILDASM: ldc.r8 2. ldc.r8 3. call float64[mscorlib]System.Math::Pow(float64, float64) Can

  • 0

the C# call

Math.Pow(2,3);

in ILDASM:

ldc.r8   2.
ldc.r8   3.
call     float64[mscorlib]System.Math::Pow(float64, float64)

Can someone please tell me how to emit that call statement via an ILGenerator ? Thanks.

  • 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-27T09:58:19+00:00Added an answer on May 27, 2026 at 9:58 am

    Here’s an example of building a dynamic method that will call the static Math.Pow(double, double) method:

    using System;
    using System.Linq;
    using System.Reflection.Emit;
    
    class Program
    {
        static void Main()
        {
            // define the signature of the dynamic method
            var powIt = new DynamicMethod(
                "PowIt",
                typeof(double),
                new Type[] { typeof(double), typeof(double) },
                typeof(Program).Module
            );
    
            // get a MethodInfo pointer to the Math.Pow(double, double) static
            // method that we are willing to use in our dynamic method
            var pow = typeof(Math).GetMethod("Pow", new[] { typeof(double), typeof(double) });
    
            var il = powIt.GetILGenerator();
            // Push the first argument onto the evaluation stack
            il.Emit(OpCodes.Ldarg_0);
            // Push the second argument onto the evaluation stack
            il.Emit(OpCodes.Ldarg_1);
            // Invoke the Math.Pow static method that we obtained a MethodInfo earlier
            // by passing the two arguments that are on the evaluation stack
            il.Emit(OpCodes.Call, pow);
    
            // Return from the method pushing a return value from the callee's evaluation stack onto the caller's evaluation stack
            il.Emit(OpCodes.Ret);
    
            // build a delegate from the dynamic method
            var func = (Func<double, double, double>)powIt.CreateDelegate(typeof(Func<double, double, double>));
    
            // Now invoke the delegate
            Console.WriteLine(func(2, 3));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a simple call to the pow() function from math.h
Someone has suggested to me that the built in C# Math.Sqrt function in .NET
I've noticed that when I call Math.Round and supply it with a decimal value
i'm developing a math/statistical software. I would like that my customer can write something
I have this problem >>> import math >>> math.pow(-1.07,1.3) Traceback (most recent call last):
When attempting to call functions in math.h , I'm getting link errors like the
Is there is a library for invoking math symbols/formula(not sure what to call), which
I call addNotify() method in class that I posted here. The problem is, that
is there an possibility to call the Math.Sin()-function in a Linq To Entites (Entity
I have a simple function to do simple math operations. If I call this

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.