I have a function that is passed to Select
. But when I put a breakpoint in said function the program does not break.
Example:
public static int PlusTwo(int x)
{
return x + 2;
}
public static void Main(string[] args)
{
var foo = new[] { 2, 3, 5, 7 };
var bar = foo.Select(PlusTwo);
}
That's because of the lazy evaluation. If you try doing a ToList()
, the function would evaluate and the break-point would be hit - i.e. try doing:
var bar = foo.Select(PlusTwo).ToList();