D
DagoFlores
Hi, let's take a look to this code that we already know.:
List<string> dinosaurs = new List<string>();
dinosaurs.Add("Compsognathus");
dinosaurs.Add("Amargasaurus");
....
List<string> sublist = dinosaurs.FindAll(EndsWithSaurus);
....
// Search predicate returns true if a string ends in "saurus".
private static bool EndsWithSaurus(String s){
Is a list of strings, and find all items that make match with the
predicate EndsWithSaurus.
But, what about if I want to work with another type than String or
Integer types ? I mean that an object of type Animal that contains
properties that I can do the FindAll method like FindAll(Animal,
HasWings) then the predicate check if the animal has wings and return
true.
In other words, there is any way to change the rigid comparison with
constants ("saurus") by thisMatch ?
private static bool EndsWithSaurus(String s)
{
if ((s.Length > 5) &&
(s.Substring(s.Length - 6).ToLower() == "saurus"))
{
like this :
private static bool EndsWithSaurus(String s, String thisMatch)
{
if ((s.Length > 5) &&
(s.Substring(s.Length - 6).ToLower() == thisMatch))
{
Thank you,
List<string> dinosaurs = new List<string>();
dinosaurs.Add("Compsognathus");
dinosaurs.Add("Amargasaurus");
....
List<string> sublist = dinosaurs.FindAll(EndsWithSaurus);
....
// Search predicate returns true if a string ends in "saurus".
private static bool EndsWithSaurus(String s){
Is a list of strings, and find all items that make match with the
predicate EndsWithSaurus.
But, what about if I want to work with another type than String or
Integer types ? I mean that an object of type Animal that contains
properties that I can do the FindAll method like FindAll(Animal,
HasWings) then the predicate check if the animal has wings and return
true.
In other words, there is any way to change the rigid comparison with
constants ("saurus") by thisMatch ?
private static bool EndsWithSaurus(String s)
{
if ((s.Length > 5) &&
(s.Substring(s.Length - 6).ToLower() == "saurus"))
{
like this :
private static bool EndsWithSaurus(String s, String thisMatch)
{
if ((s.Length > 5) &&
(s.Substring(s.Length - 6).ToLower() == thisMatch))
{
Thank you,