troubleshooting Question

LINQ converting to a list or array to pass to another method.

Avatar of z488758
z488758Flag for Australia asked on
3 Comments1 Solution372 ViewsLast Modified:

I have a datatable of data. I want to convert a subset and sepecific columns of the table data to a class object to pass to another method for analysis. I am trying to convert to a list to pass. Assistance to advise how to would be appreciated, either a smarter way or how to make this way work.

Class as follows
public class clsData
            public decimal Back;
            public decimal Mean;

Have data in a table, and trying to use LINQ to create a list (or array) to pass to a method as can't pass a VAR object.

   var PastData = (from c in results
                                       select new
                                           Back = c.Field<decimal>("Price"),
                                           QMean = c.Field<decimal>("QMean")                                        
Have tried to cast to the ClsData object without success. Then would want to receiveit in the method with something like

Public void List<ClsData> cd

Any advice would be appreciated
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros