pluralsight-linq-fundamentals/Features/MyLinq.cs

20 lines
485 B
C#
Raw Normal View History

2021-02-24 13:49:26 +11:00
using System.Collections.Generic;
namespace Features
{
public static class MyLinq
{
// Implement a customized LINQ using extension
public static int MyLinqCount<T>(this IEnumerable<T> sequence)
{
// Any IEnumerable<T> instance can use this method now as extension
int count = 0;
foreach (var item in sequence)
{
count += 1;
}
return count;
}
}
}