why does 13 get printed out in the code below?
13 is not less 13 so it should not be be printed out, right?
13 is not less 13 so it should not be be printed out, right?
C#:
using System;
using System.Collections.Generic;
delegate void FooDelagate(string xx);
class Program
{
public static void Main()
{
List<int> L = new List<int>();
L.Add(7);
L.Add(11);
L.Add(17);
L.Add(13);
IEnumerable<int> result = GetNumbersLessThanThirteen(L);
foreach(int s in L)
{
Console.WriteLine(s);
}
}
public static IEnumerable<int> GetNumbersLessThanThirteen(List<int> numbers)
{
foreach(int n in numbers)
{
if(n<13)
{
yield return n;
}
}
}
}
Last edited by a moderator: