I looked at this code on MSDN ( and at article in MSDN magazine this month ):
The code below suggests that I may be able to use the find function of
generics to locate the object easily as opposed to a FOR Loop.
public List<stringdinosaurs = new List<string>();
....
dinosaurs.Add("Compsognathus");
dinosaurs.Add("Amargasaurus");
....
List<stringsublist = dinosaurs.FindAll(EndsWithSaurus); // iterates the
list// repeatedly calling function
private static bool EndsWithSaurus(String s)
{
if ((s.Length 5) && (s.Substring(s.Length - 6).ToLower() == "saurus"))
{
return true;
}
else
{
return false;
}
}
BUT ........
I have 2 issues, (1) I need to convey to the FIND what needs to be compared
dynamically, and (2) I need a way for the find to use it..- So far it wont
compile.
Suggestions please and THANK YOU in advance..
private List<FileRevisonInfolstReleaseFiles= new List<FileRevisonInfo>();
// fill my objects, add to list...
List<FileRevisonInfosublist =
(FileRevisonInfo)lstReleaseFiles.Find(FindFieldNam e);
// WONT COMPILE Error 2 Cannot implicitly convert type
'MasterRelease2.FileRevisonInfo' to 'System.Collections.Generic.List
//<MasterRelease2.FileRevisonInfo>'
private static bool FindFieldName(FileRevisonInfo s)
{//must it read a property for theFieldName to be dynamic ??
string theFieldName = ""; // placeholder until method understood. ??
if (s.FName.ToUpper() == theFieldName)
{ return true; }
else
{ return false;}
}
--
Andrew