Как получить сумму всех результатов.parent1? Я использую linqpad. функция дампа помещает его в таблицу, но я хотел бы распечатать его через console.write. Как я могу добиться того же?
void Main()
{
List a = new List();
a.Add(new parent(2, true));
a.Add(new parent(3, false));
a.Add(new parent(4, true));
List results = a.FindAll(
delegate (parent p)
{
return p.child1 == true;
});
if (results.Count > 0)
{
//how do i find the sum of all the results.parent1?
results.Dump();
Console.Write("sum of all the results.parent1? ");
}
}
///
/// This file holds all user defined indicator methods.
///
public class parent
{
int v;
public parent(double d, bool b)
{
this.parent1 = d;
this.child1 = b;
}
public double parent1 { get; set; }
public bool child1 { get; set; }
}
Подробнее здесь: https://stackoverflow.com/questions/738 ... a-property