Sha*_*pta 0 c# delegates anonymous-types
我正在尝试实施以下内容.如果发现任何按钮被更改,我需要返回true.我不想再循环了.
因为ForEach正在寻找Action Type Delegate.因此可以从deletage中返回bool值
public bool AreSettingChanged()
{
objRpmButtonHolder.RpmButtonCollection.ForEach(btn
=> {
if (btn.IsChanged)
return true;
});
return true;
}
Run Code Online (Sandbox Code Playgroud)
试试这个
public bool AreSettingChanged()
{
return objRpmButtonHolder.RpmButtonCollection.Any(b => b.IsChanged);
}
Run Code Online (Sandbox Code Playgroud)