Last active
May 4, 2016 11:37
-
-
Save mrtank/cf0076148854e34e6385ab5db075afa4 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
var numberList = new List<int>(); | |
numberList.AddRange(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); | |
var totalNumber = 0; | |
foreach (var item in YieldingNotFive(numberList)) | |
{ | |
totalNumber += item; | |
} | |
private IEnumerable<int> YieldingNotFive(List<int> numberList) | |
{ | |
foreach (int item in numberList) | |
{ | |
if (item != 5) | |
{ | |
yield return item; | |
} | |
} | |
yield break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment