Skip to content

Instantly share code, notes, and snippets.

@mrtank
Last active May 4, 2016 11:37
Show Gist options
  • Save mrtank/cf0076148854e34e6385ab5db075afa4 to your computer and use it in GitHub Desktop.
Save mrtank/cf0076148854e34e6385ab5db075afa4 to your computer and use it in GitHub Desktop.
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