Look at Predicate Generic Delegate in MSDN, which provides basic sample.
Extract from sample
// To find the first Point structure for which X times Y
// is greater than 100000, pass the array and a delegate
// that represents the ProductGT10 method to the Shared
// Find method of the Array class.
Point first = Array.Find(points, ProductGT10);
// Note that you do not need to create the delegate
// explicitly, or to specify the type parameter of the
// generic method, because the C# compiler has enough
// context to determine that information for you.
// Display the first structure found.
Console.WriteLine("Found: X = {0}, Y = {1}", first.X, first.Y);
Note that you don't need create delegate and you can use in-class method:
// This method implements the test condition for the Find
// method.
private static bool ProductGT10(Point p)
{
if (... return false;
}
}
}
As you can see you pass "method to method" - namely, delegate, which is
somewhat similat to anonymous method - if to forget that you can use
ProductGT10 also as standard static method.
HTH
Alex
"Lit" <sq**********@hotmail.comwrote in message
news:Oc**************@TK2MSFTNGP04.phx.gbl...
Hi,
Can someone explain this:
<this is from Using generic- By Ludwig Stuyck>
string nameToFind = "Ludwig Stuyck";
PersonNameFilter personNameFilter = new PersonNameFilter(nameToFind);
// Create a new predicate, that uses the FilterByName method to determine
whether the person has been found
Predicate<PersonfilterByName = new
Predicate<Person>(personNameFilter.FilterByName);
// Find the person in the collection
Person foundPerson = persons.Find(filterByName);
?? Are we passing a method to a method or what
?? is this similar to anonymous methods.
?? can not see the fully understand it or see the full power yet, but I
know/heard it is very powerful
Thanks
Lit.