Created
March 19, 2014 07:15
-
-
Save callumj/9636863 to your computer and use it in GitHub Desktop.
Helper code for ASP.NET MVC alternating
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OddEvenWrapper<T> | |
{ | |
public T Object { get; set; } | |
public bool Even { get; set; } | |
} | |
public static IEnumerable<OddEvenWrapper<T>> AlternateOddEven<T>(IEnumerable<T> list) | |
{ | |
bool even = false; | |
foreach(T obj in list) | |
{ | |
yield return new OddEvenWrapper<T> | |
{ | |
Object = obj, | |
Even = even | |
}; | |
even = !even; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment