Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bitbonk
Created November 25, 2016 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitbonk/6d4be0d6427effb5d9b6e937a36e4cc1 to your computer and use it in GitHub Desktop.
Save bitbonk/6d4be0d6427effb5d9b6e937a36e4cc1 to your computer and use it in GitHub Desktop.
ctor geruden von ToList()
public List(IEnumerable<T> collection)
{
if (collection == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
ICollection<T> objs = collection as ICollection<T>;
if (objs != null)
{
int count = objs.Count;
if (count == 0)
{
this._items = List<T>._emptyArray;
}
else
{
this._items = new T[count];
objs.CopyTo(this._items, 0);
this._size = count;
}
}
else
{
this._size = 0;
this._items = List<T>._emptyArray;
foreach (T obj in collection)
this.Add(obj);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment