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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:47:38+00:00 2026-05-11T03:47:38+00:00

I want to do this: MethodInfo m = myList.GetType().GetMethod(ConvertAll, System.Reflection.BindingFlags.InvokeMethod).MakeGenericMethod(typeof(object)); List<object> myConvertedList = (List<object>)m.Invoke(myList,

  • 0

I want to do this:

MethodInfo m = myList.GetType().GetMethod('ConvertAll', System.Reflection.BindingFlags.InvokeMethod).MakeGenericMethod(typeof(object)); List<object> myConvertedList = (List<object>)m.Invoke(myList, new object[]{ (t => (object)t)}); 

myList is a generic list of a specific type (unknown to the application), and I want to convert it to a list of objects to do some operations.

However this fails with this error: ‘Cannot convert lambda expression to type ‘object’ because it is not a delegate type’

Can you help me find what’s wrong? Am I trying to do something that’s not possible?

Is there some other way to achieve the same thing?

  • 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. 2026-05-11T03:47:39+00:00Added an answer on May 11, 2026 at 3:47 am

    A lambda expression is convertible to either a delegate type or an expression tree with the right signature – but you need to specify which delegate type it is.

    I think your code would be much simpler if you made this a generic method:

    public static List<object> ConvertToListOfObjects<T>(List<T> list) {     return list.ConvertAll<object>(t => t); } 

    Then you just need to find and invoke that method generically:

    MethodInfo method = typeof(Foo).GetMethod('ConvertToListOfObjects',     BindingFlags.Static | BindingFlags.Public); Type listType = list.GetType().GetGenericArguments()[0]; MethodInfo concrete = method.MakeGenericMethod(new [] { listType }); List<object> objectList = (List<object>) concrete.Invoke(null,                                                     new object[]{list}); 

    Complete example:

    using System; using System.Reflection; using System.Collections.Generic;  class Test {     public static List<object> ConvertToListOfObjects<T>(List<T> list)     {         return list.ConvertAll<object>(t => t);     }      static void Main()     {         object list = new List<int> { 1, 2, 3, 4 };          MethodInfo method = typeof(Test).GetMethod('ConvertToListOfObjects',             BindingFlags.Static | BindingFlags.Public);         Type listType = list.GetType().GetGenericArguments()[0];         MethodInfo concrete = method.MakeGenericMethod(new [] { listType });         List<object> objectList = (List<object>) concrete.Invoke(null,                                                     new object[] {list});          foreach (object o in objectList)         {             Console.WriteLine(o);         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've managed to simulate this situation: To do a normal… May 11, 2026 at 11:44 pm
  • Editorial Team
    Editorial Team added an answer The viewDidLoad method is only called when the view is… May 11, 2026 at 11:44 pm
  • Editorial Team
    Editorial Team added an answer Isn't the 6510 in the C64? You might be able… May 11, 2026 at 11:44 pm

Related Questions

I'm using LINQ-to-XML to query a file for a list of objects. They all
For a given class I would like to have tracing functionality i.e. I would
I want to invoke methods with a certain attribute. So I'm cycling through all
I want to programmatically invoke an event handler for a control. For example: DateTimePicker

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.