Abhi,
Which list are you trying to check to see if the value exists?
Basically, you want to pass the predicate to the list in order to see if the
values that are already in the list meet a certain condition.
You might want to use anonymous delegates here, as they will allow you
to specify the condition much easier depending on what you have set up.
Can you give a code sample, as well as a more detailed explaination of
what the condition you are trying to check is?
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Abhi" <ku******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
In the following hypothetical example I want to build a generic list
of unique string items.
How should I implement the pred function so that it returns true/false
if target string exists in the generic list...is not clear to me. Any
suggestions?
System.Collections.Generic.List<string> list = new
System.Collections.Generic.List<string>();
foreach(string s in myAnotherArray)
{
System.Predicate<string> p = new System.Predicate<string> (pred);
if(!list.Exists(p))
{
list.Add(s);
}
}
protected bool pred(string target)
{
//TODO: How to find out target string exists in the generic
list????
}