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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:19:33+00:00 2026-05-31T11:19:33+00:00

I am trying to use the function found here: DataTable to List<object> public static

  • 0

I am trying to use the function found here:
DataTable to List<object>

  public static IList<T> ConvertTo<T>(DataTable table)
        {
            if (table == null)
                return null;

            List<DataRow> rows = new List<DataRow>();

            foreach (DataRow row in table.Rows)
                rows.Add(row);

            return ConvertTo<T>(rows);
        }

the return statement is giving me an exception stating:

The best overloaded method match for 'Utilities.Utility.ConvertTo<T>(System.Data.DataTable)' has some invalid arguments

Can someone help me fix this error??

  • 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-31T11:19:34+00:00Added an answer on May 31, 2026 at 11:19 am

    Don’t do it that way use Marc’s amazing function ( https://stackoverflow.com/a/545429/215752 ) I mean really… that is exactly what you want.. right?


    You need another function

    public static IList<T> ConvertTo<T>(IList<DataRow> rows)
        {
            IList<T> list = null;
    
            if (rows != null)
            {
                list = new List<T>();
    
                foreach (DataRow row in rows)
                {
                    T item = CreateItem<T>(row);
                    list.Add(item);
                }
            }
    
            return list;
        }
    

    The question you link had a link in it. I’d suggest looking there for more info:

    http://lozanotek.com/blog/archive/2007/05/09/Converting_Custom_Collections_To_and_From_DataTable.aspx

    There you will find all the code, which I expect will compile. I won’t vouch for the reliability or reasonably of using it however.

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

Sidebar

Related Questions

I am trying to use the jquery msgbox addon found here: http://jquerymsgbox.yazdimoldu.tk/ The function
I am trying to use the function Z3_benchmark_to_smtlib_string(). Here are the arguments I am
I'm trying to use a function with PostgreSQL to save some data. Here is
Hi I'm trying to use the CakePHP comments plugin found here http://cakedc.com/downloads/view/cakephp_comments_plugin but the
I am trying to use the jQuery UI datetimepicker found here . I put
OK, so I'm trying a to use a cool image loader/gallery I found here
I am trying to use this function from a COM API which enables the
I'm trying to use the function XLookupString . According to the documentation , it
I was trying to use the function glMultiDrawElements while studying OpenGL (using red book)
I am trying to use a function pointer and I am getting this error:

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.