20 lines
485 B
C#
20 lines
485 B
C#
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|