Skip to content

Instantly share code, notes, and snippets.

@callumj
Created March 19, 2014 07:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save callumj/9636863 to your computer and use it in GitHub Desktop.
Helper code for ASP.NET MVC alternating
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