In Umbraco 7, I used the extensions for isFirst() and isLast() extensively. They're apparently gone in U8. Is there an easy way that doesn't require 10 lines of code to get these functions back?
public static class IEnumerableExtensions
{
public static bool IsLast<T>(this IEnumerable<T> items, T item)
{
var last = items.LastOrDefault();
if (last == null)
return false;
return item.Equals(last); // OR Object.ReferenceEquals(last, item)
}
public static bool IsFirst<T>(this IEnumerable<T> items, T item)
{
var first = items.FirstOrDefault();
if (first == null)
return false;
return item.Equals(first);
}
}
U8: Postion(), isFirst(), isLast(), etc.
In Umbraco 7, I used the extensions for isFirst() and isLast() extensively. They're apparently gone in U8. Is there an easy way that doesn't require 10 lines of code to get these functions back?
Hi Robert,
Just add these extensions to your project
That’s super helpful, thanks!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.