Imperative
Imperative | Declarative |
---|---|
You say how to get what you want | You just say what you want |
Imperative
List<int> results = new List<int>();
foreach(var num in collection)
{
if (num % 2 != 0)
results.Add(num);
}
Here, we're saying:
- Create a result collection
- Step through each number in collection
- Check the number. If its odd, add it to the results
Backlinks