我想发布这个问题的答案,因为MSDN网络示例仅列出了C#和VB,答案在C ++ / CLI中略有不同。
这个答案来自这篇文章:Using "->Find" on a "List" in Visual C++
答案 0 :(得分:0)
遵循帖子链接above ...
的指导首先,我创建了一个用作我的谓词委托的类:
public value class FindComponentView
{
String^ Value;
public:
FindComponentView(String^ value)
{
Value = value;
}
bool IsMatch(ComponentDrawingData^ compDD)
{
return compDD->Identifier->Value == Value;
}
};
然后我能够像这样实现Find()方法:
// 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));