Created
October 27, 2017 16:17
-
-
Save rquackenbush/93961e6b2bdf8efc4e588ebf9d771845 to your computer and use it in GitHub Desktop.
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
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