Resharper’s example code for explaining “Possible multiple enumeration of IEnumerable”

GetNames() returns an IEnumerable. So if you store that result: IEnumerable foo = GetNames(); Then every time you enumerate foo, the GetNames() method is called again (not literally, I can’t find a link that properly explains the details, but see IEnumerable.GetEnumerator()). Resharper sees this, and suggests you to store the result of enumerating GetNames() in … Read more