List<T>的ForEach方法(可以使用“语句lambda”作为其参数),如下例子:

private void OKButton_Click(object sender, RoutedEventArgs e) {
            this.DialogResult = true;
      //  GetSelectedJZ(Shu.Items[0] as TreeViewItem);
            //选择后返回
            if (GetJZ_Event!=null) {
            //排除不是建筑的选项
                V_FQ.Rows.Where(a =>
                V_FQ.Value(a, "cc").ToString() == "1"
                ).ToList().ForEach(b => {
                    if (Shu.SelectedItemsZJ.Contains(V_FQ.Value(b, "zj").ToString()))
                        Shu.SelectedItemsZJ.Remove(V_FQ.Value(b, "zj").ToString());
                });
                GetJZ_Event(Shu.SelectedItemsZJ);
            }
        }

 _graphicsManager.Graphics.Where<Graphic>(
                        (item) =>
                        {
                            if ((ShowAperture)item.Symbol.GetValue(PolicePictureMarkerSymbol.ShowApertureProperty) == ShowAperture.Yes)
                            {
                                item.SetShowAperture(ShowAperture.No);
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    );


                    _graphicsManager.Graphics.Where<Graphic>(item => (ShowAperture)item.Symbol.GetValue(PolicePictureMarkerSymbol.ShowApertureProperty) == ShowAperture.Yes).ToList().ForEach(p => p.SetShowAperture(ShowAperture.No));

                    _graphicsManager.Graphics.Where<Graphic>(item => (ShowAperture)item.Symbol.GetValue(PolicePictureMarkerSymbol.ShowApertureProperty) == ShowAperture.Yes).ToList().ForEach((p) =>
                        {
                            p.SetShowAperture(ShowAperture.No);
                        });

原文地址:https://www.cnblogs.com/changbaishan/p/3107436.html