Liste <> .ForEach nicht gefunden [duplizieren]
Diese Frage hat hier bereits eine Antwort:
Ist die List <T> .ForEach () -Methode weg? 3 AntwortenIch portiere eine Windows Phone-App auf Win 8 und habe diesen Stolperstein gefunden, kann aber keine Lösung finden.
Ich habe ein:
List<items> tempItems = new List<items>();
und
ObservableCollection<items> chemists = new ObservableCollection<items>();
Ich habe meinen tempItems usw. Elemente hinzugefügt. Dann mache ich Folgendes:
tempItems.OrderBy(i => i.Distance)
.Take(20)
.ToList()
.ForEach(z => chemists.Add(z));
Aber ich bekomme diesen Fehler:
Error 1 'System.Collections.Generic.List<MyApp.items>' does not contain a definition for 'ForEach' and no extension method 'ForEach' accepting a first argument of type 'System.Collections.Generic.List<MyApp.items>' could be found (are you missing a using directive or an assembly reference?)
Warum könnte das sein, hat Win8 diese Funktion nicht? Ich beziehe mich auf Folgendes:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Xml.Linq;
using Windows.Devices.Geolocation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
using System.Collections.ObjectModel;
Wenn ForEach nicht verfügbar ist, gibt es eine Alternative, die dasselbe tut?