Possible multiple enumeration of IEnumerable

 

When I use IEnumerable more than once, ReSharper recommends I convert IEnumerable to an Array or List.

I try to understand why ReSharper uses 'as' as the first option to convert the IEnumerable to Array, is it faster? or why?

var arr = e as int[] ?? e.ToArray();

0
1 comment
Official comment

Hello Alejandro!

 

Thank you for contacting us.

Please refer to the following help article which describes how does the inspection works - https://www.jetbrains.com/help/resharper/PossibleMultipleEnumeration.html

Thank you.

Please sign in to leave a comment.