create a generic method using IEnumerable<T> and delegate

  • Thread starter Thread starter essamce
  • Start date Start date
E

essamce

Guest
hi

i want to implement a method like Distinct() in LINQ,


public static void Unique<T>(ref IEnumerable<T> list, Func<T,T, bool> comparer)
{

for (int i = 0; i < list.Count(); i++)
{
for (int j = i + 1; j < list.Count(); j++)
{
if (comparer(list, list[j])) //error
{
list.RemoveAt(j); // error
j--;
}
};
};

}

Continue reading...
 
Back
Top