foreach loop works on everything that implement IEnumerable (lists, sets, collection, arrays, etc). So when you take for example the following line
```cs
foreach (var canvas in candidates ?? population)
```
it will enumerate either candidates, or when thats null, for the complete population
since candidate and population both implement IEnumerable<ICanvas> the type of `var` is ICanvas. This is done compile time, not run time, so you can actually hover over `var` to find out it's type

The verbose syntax will be more Java-ish:
```cs
IEnumerable<ICanvas> temp;
if (candidates!=null) temp = candidates;
else temp = population
foreach (ICanvas in temp)
{
...
```
But once you get the syntax, it's more readable to do the short version imho.