ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Parameter type can be IEnumerable<T> (non-private accessibility)

Last modified: 08 April 2024

If you have a method whose parameter is an array, a List, or some other type that implements IEnumerable<T>, ReSharper offers an option to change the parameter type to IEnumerable<T> — provided that the method itself only iterates the collection and does not access any non-IEnumerable members.

The benefit from this change is that the method becomes agnostic with respect to the type of the collection you pass to it.