foreach (int i in temp)
data.Add(i);
where temp
is a List
and data
is an ObservableCollection
foreach (int i in temp)
data.Add(i);
where temp
is a List
and data
is an ObservableCollection
// if data is empty just pass temp in the constructor
ObservableCollection<int> data = new ObservableCollection<int>(temp);
// if data already has values you can do this using List.ForEach method
// but this would not be a LINQ since LINQ not able to modify data sources itself
temp.ForEach(i => data.Add(i));
Not really anything wrong with what you got. ObservableCollection is a bit of a pain tho.
Here are some useful extension methods that add things like an 'AddRange' method for it.
http://zainshaikh.posterous.com/some-extension-methods-for-observablecollecti