Something like (pseudo code)
ObservableCollection<TheClass> ob1 = new ObservableCollection<TheClass>();
ob1.Add(...);
ob1.Add(...);
ob1.Add(...);
ob1.Add(...);
ObservableCollection<TheClass> ob2;
ob2 = ob1.Range(0, 2);
Keeping into account that both collections can contains a large amount of data.
thanks
ObservableCollection<TheClass> ob1 = new ObservableCollection<TheClass>();
ob1.Add(...);
ob1.Add(...);
ob1.Add(...);
ob1.Add(...);
ObservableCollection<TheClass> ob2;
// ob2 = ob1.Range(0, 2);
ob2 = new ObservableCollection(ob1.Skip(0).Take(2));
Now if you really insist on that .Range
method, you could write an extension yourself:
public static class ObservableCollectionExtensions
{
public static ObservableCollection<T> Range(this ObservableCollection<T> sequence, int start, int count)
{
return new ObservableCollection(sequence.Skip(start).Take(count));
}
}
Now your code should compile:
ObservableCollection<TheClass> ob1 = new ObservableCollection<TheClass>();
ob1.Add(...);
ob1.Add(...);
ob1.Add(...);
ob1.Add(...);
ObservableCollection<TheClass> ob2;
ob2 = ob1.Range(0, 2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With