Use LINQ and C# to make a new List from an old List
Posted
by Addie
on Stack Overflow
See other posts from Stack Overflow
or by Addie
Published on 2010-03-15T06:14:09Z
Indexed on
2010/03/15
6:19 UTC
Read the original article
Hit count: 304
This should be pretty simple, but I am new at LINQ. I have a List of FillList structs. I'd like to use LINQ to create a new List where instead of having the number of buys and sells, I would have one variable containing the sum.
For example, if the FillStruct structure has
buy = 4
and
sell = 2
then the NewFillStruct structure will have
numlong = 2.
If the FillStruct structure has
buy = 2
and
sell = 4
then the NewFillStruct structure will have
numlong = -2.
Here are the structures.
struct FillStruct
{
int buy;
int sell;
string date;
}
struct NewFillStruct
{
int numlong;
string date;
}
© Stack Overflow or respective owner