Skip to content

Commit 97a76b8

Browse files
RexJaeschkejskeet
authored andcommitted
Create ItemListT.cs
1 parent 824ef05 commit 97a76b8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class ItemList<T> : List<T>
2+
{
3+
public int Sum(Func<T, int> selector)
4+
{
5+
int sum = 0;
6+
foreach (T item in this)
7+
{
8+
sum += selector(item);
9+
}
10+
return sum;
11+
}
12+
13+
public double Sum(Func<T, double> selector)
14+
{
15+
double sum = 0;
16+
foreach (T item in this)
17+
{
18+
sum += selector(item);
19+
}
20+
return sum;
21+
}
22+
}

0 commit comments

Comments
 (0)