public static T[] Remaining<T>(this T[] list, T exclude) 

{

   return list.Except(new T[] { exclude }).ToArray();

}

 

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of David Burstin
Sent: Wednesday, 28 July 2010 12:09
To: ozDotNet
Subject: Generics, operators and native data types

 

Hi all,

 

public static T[] Remaining<T>(this T[] list, T exclude) 

{

return list.Where(s => s != exclude).ToArray();

}

 

gives me a "Cannot apply operator '!=' to operands of type T and T".

 

Basically, I want to pass in an array and have it return an array without
the element [exclude]. The array can be strings, chars or ints.

 

Any suggestions?

 

Cheers

Dave 

Reply via email to