Skip to content

Instantly share code, notes, and snippets.

@rquackenbush
Created October 27, 2017 16:17
Show Gist options
  • Save rquackenbush/93961e6b2bdf8efc4e588ebf9d771845 to your computer and use it in GitHub Desktop.
Save rquackenbush/93961e6b2bdf8efc4e588ebf9d771845 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
namespace CaptiveAire.Scada.Module.Base.Extensions
{
public static class IEnumerableExtensions
{
public static int? IndexOfOrNull<T>(this IEnumerable<T> items, Func<T, bool> func)
{
int index = 0;
foreach (var item in items)
{
if (func(item))
{
return index;
}
index++;
}
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment