Created
May 9, 2017 09:38
-
-
Save Grinderofl/43c5c1cb771dac0d60597d9da3a5f8ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<YourType> GetYourTypes() | |
{ | |
yield return GetElement(); | |
foreach(var el in GetOtherElements()) | |
yield return el; | |
} | |
var types = GetYourTypes(); | |
if(!types.Any()) // possible multiple enumerations of enumerable | |
// Do something | |
foreach(var type in types) // possible multiple enumerations of enumerable | |
// Do something | |
vs | |
var types = GetYourTypes.ToList(); | |
if(!types.Any()) | |
// Do something | |
foreach(var type in types) | |
// Do something | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment