Code: Select all
MyCollection coll = new MyCollection([1, 2, 3]);
MyCollection myColl = [.. coll];
Code: Select all
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
[CollectionBuilder(typeof(MyCollection), nameof(Create))]
public class MyCollection : ICollection
{
public static MyCollection Create(ReadOnlySpan values) =>
new(values);
int[] _values;
public int Count => _values.Length;
public MyCollection(ReadOnlySpan values) =>
_values = values.ToArray();
public IEnumerator GetEnumerator() => throw new NotImplementedException();
IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();
public bool IsReadOnly => throw new NotImplementedException();
public void Add(int item) => throw new NotImplementedException();
public void Clear() => throw new NotImplementedException();
public bool Contains(int item) => throw new NotImplementedException();
public void CopyTo(int[] array, int arrayIndex) => throw new NotImplementedException();
public bool Remove(int item) => throw new NotImplementedException();
}