z488758
asked on
LINQ converting to a list or array to pass to another method.
Hi
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")
}).ToList();
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
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")
}).ToList();
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Awesome. Glad to help = )
ASKER