问题
I wanted to post an answer to this question because the MSDN Network Example only lists C# and VB and the answer is a bit different in C++/CLI.
This answer is derived from this post: Using "->Find" on a "List" in Visual C++
回答1:
Following the guidance of the post link above...
First I created a class to use as my Predicate delegate:
public value class FindComponentView
{
String^ Value;
public:
FindComponentView(String^ value)
{
Value = value;
}
bool IsMatch(ComponentDrawingData^ compDD)
{
return compDD->Identifier->Value == Value;
}
};
I was then able to implement the Find() method like this:
// Note: ComponentDrawingDataList^ derives from System::Collections::Generic::List<T>^
ComponentDrawingDataList^ ddList = GetComponentDrawingDatas(component);
ComponentDrawingData^ componentDrawingData =
ddList->Find(gcnew System::Predicate<ComponentDrawingData^>(gcnew FindComponentView("View_1"), &FindComponentView::IsMatch));
来源:https://stackoverflow.com/questions/37354500/how-do-i-create-a-custom-find-method-for-a-genericlistt-in-c-cli