You could bypass the List<T>'s tendency to use ICollection<Tby
simply not giving it an ICollection<T- for example, with the C# 3
extension method below you could use:
List<Tlist = new List<T>(source.AsEnumerableOnly());
The AsEnumerableOnly() *only* exposes IEnumerable<T(OK, it also
exposes IEnumerable and IDisposable ;-p), allowing your non-Count-
friendly implementation to work happily.
Marc
public static class EnumerableExt
{
public static IEnumerable<TAsEnumerableOnly<T>(
this IEnumerable<Tsource)
{
if (source == null) yield break; // GIGO
foreach (T item in source)
{
yield return item;
}
}
}