|
|
|
|
|
by usea
4718 days ago
|
|
I agree with your pain points. We try to use ICollection in our APIs instead of IEnumerable, since the latter can have surprising semantics like being a wrapper for some operation which may not be valid anymore, or might be slower than you expect to do things like .Count(). IMO it's really not best for transporting across interface boundries in the most common case; only when you're specifically trying to avoid having the whole collection in memory or something like that. Another thing that can help is this wonderful May<T> library[1]. It a great option type[2] for .NET. It helps make operations more composable. [1] https://github.com/Strilanc/May [2] http://en.wikipedia.org/wiki/Option_type |
|