fix AddRange

This commit is contained in:
neuecc 2021-09-07 19:26:57 +09:00
parent e0539969b3
commit 5d27ee38a7
3 changed files with 5 additions and 2 deletions

View File

@ -7,7 +7,9 @@ namespace ConsoleApp
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
var oc = new ObservableList<int>();
oc.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }.AsEnumerable());
} }
} }

View File

@ -22,6 +22,7 @@ namespace ObservableCollections.Internal
{ {
this.array = ArrayPool<T>.Shared.Rent(1); this.array = ArrayPool<T>.Shared.Rent(1);
this.length = 1; this.length = 1;
this.array[0] = item;
} }
public CloneCollection(IEnumerable<T> source) public CloneCollection(IEnumerable<T> source)
@ -113,7 +114,7 @@ namespace ObservableCollections.Internal
public void Add(T item) => throw new NotSupportedException(); public void Add(T item) => throw new NotSupportedException();
public void Clear() => throw new NotSupportedException(); public void Clear() => throw new NotSupportedException();
public bool Contains(T item) => throw new NotSupportedException(); public bool Contains(T item) => throw new NotSupportedException();
public void CopyTo(T[] dest, int destIndex) => array.CopyTo(dest, destIndex); public void CopyTo(T[] dest, int destIndex) => Array.Copy(array, 0, dest, destIndex, count);
public IEnumerator<T> GetEnumerator() public IEnumerator<T> GetEnumerator()
{ {

View File

@ -114,7 +114,7 @@ namespace ObservableCollections.Internal
public void Add(T item) => throw new NotSupportedException(); public void Add(T item) => throw new NotSupportedException();
public void Clear() => throw new NotSupportedException(); public void Clear() => throw new NotSupportedException();
public bool Contains(T item) => throw new NotSupportedException(); public bool Contains(T item) => throw new NotSupportedException();
public void CopyTo(T[] dest, int destIndex) => array.CopyTo(dest, destIndex); public void CopyTo(T[] dest, int destIndex) => Array.Copy(array, 0, dest, destIndex, count);
public IEnumerator<T> GetEnumerator() public IEnumerator<T> GetEnumerator()
{ {