A discussion I've been involved with recently has been an updated guideline around the return types of interfaces. It was decided that IEnumerable ...
For further actions, you may consider blocking this person and/or reporting abuse
Does
IEnumerablereally indicates anything thatICollectiondoesn't?Don't forget that
ICollectioninheritsIEnumerable...I think that as a rule of thumb, you should return the simplest possible type that you can - while still make it usable for whomever is expected to use your method. If you know it will generally make sense to the results in a
foreachloop, anIEnumerableis enough. If you want to return the count as a property,IReadOnlyCollectionis a lovely option.Please note, you don't really need to know what your users are going to do - but you should base your decision on what you allow to be done with your return value.
You should probably also read this SO post and it's answers:
I am confused about which collection type that I should return from my public API methods and properties.
The collections that I have in mind are
IList,ICollectionandCollection.Is returning one of these types always preferred over the others, or does it depend on the specific…