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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:31:22+00:00 2026-06-12T22:31:22+00:00

The Run2 method is run. But the Run method is not run. What is

  • 0

The Run2 method is run. But the Run method is not run. What is the reason ?
The only difference between two methods is because parameter.

public class MyClass
{
    public string Name { get; set; }
}

[TestFixture]
public class Test
{
    public IEnumerable<T> TestMethod<T>(int i)
    {
        //do something
        return null;
    }

    public IEnumerable<T> TestMethod2<T>()
    {
        //do something
        return null;
    }

    [Test]
    public void Run()
    {
        MethodInfo mi = this.GetType().GetMethod("TestMethod").MakeGenericMethod(typeof(MyClass));
        var del = Delegate.CreateDelegate(typeof(Func<IEnumerable<MyClass>>), this, mi);
        var list = (IEnumerable<MyClass>)del.DynamicInvoke(0);
    }

    [Test]
    public void Run2()
    {
        MethodInfo mi = this.GetType().GetMethod("TestMethod2").MakeGenericMethod(typeof(MyClass));
        var del = Delegate.CreateDelegate(typeof(Func<IEnumerable<MyClass>>), this, mi);
        var list = (IEnumerable<MyClass>)del.DynamicInvoke();
    }
}
  • 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-12T22:31:24+00:00Added an answer on June 12, 2026 at 10:31 pm

    The problem is here:

    var del = Delegate.CreateDelegate(typeof(Func<IEnumerable<MyClass>>), this, mi);
    

    You’ve said to bind your method to a Func<IEnumerable<MyClass>> delegate, but the actual method should be Func<int, IEnumerable<MyClass>> (because of the int argument to TestMethod). The following should correct it:

    var del = Delegate.CreateDelegate(typeof(Func<int, IEnumerable<MyClass>>), this, mi);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with Zend Db's update() method. It's not safe against sql injection
Im not to versed in mysql JOINS, but I think that is what is
I need to run 2 identical Rails apps (different only in the underlying database)
Now i'm executing next command gnome-terminal --tab -e run1 --tab -e run2 But run1
I am trying to run 2 projects built using play framework simultaneously but with
I've got a name of a method: Garden.Plugins.Code.Beta.Business.CalculateRest How to run it? I think
Is there some way to run 2 threads at the same time? I want
What is the data actual path if I run 2 applications sending/receiving data using
I have a vmdk images of windows XP I run 2 different images on
I am not a guru of databases, do most of the things through PHP,

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.