xxxxxxxxxx
// Sample code to get the next item in an IEnumerable collection
public static T GetNextItem<T>(IEnumerable<T> collection, T currentItem)
{
bool foundCurrentItem = false;
foreach (T item in collection)
{
if (foundCurrentItem)
{
return item; // Returns the next item
}
if (item.Equals(currentItem))
{
foundCurrentItem = true;
}
}
return default(T); // Returns the default value if next item is not found
}