Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Express Yourself! Motivating Example
public int WhatDoIDo(int[] numbers)
{
return numbers.Count(i => i % 2 == 0)
}
public int WhatDoIDo(int[] numbers)
{
var count = 0;
foreach (var i in numbers)
{
if (i % 2 == 0)
{
count++;
}
}
return count;
}
public class public int WhatDoIDo(int[] numbers)
{
return numbers.Count(IsEven)
}
private static bool IsEven(int i)
{
return i % 2 == 0;
}
public int WhatDoIDo(int[] numbers)
{
return numbers.Count(i => i.IsEven());
}
public static class MathExtensions
{
public static bool IsEven(this int i)
{
return i % 2 == 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.