C# yield return performance
How much space is reserved to the underlying collection behind a method using yield return syntax WHEN I PERFORM a ToList() on it? There's a chance it will reallocate and thus decrease performance if compared to the standard approach where i create a list with predefined capacity? The two scenarios: public IEnumerable<T> GetList1() { foreach( var item in collection ) yield return item.Property; } public IEnumerable<T> GetList2() { List<T> outputList = new List<T>( collection.Count() ); foreach( var item in collection ) outputList.Add( item.Property ); return outputList; } yield return does not