Skip to content

Instantly share code, notes, and snippets.

@dyguests
Created October 16, 2022 13:36
Show Gist options
  • Save dyguests/09d4d1644d6d9cc5c7fb17a2ba69653c to your computer and use it in GitHub Desktop.
Save dyguests/09d4d1644d6d9cc5c7fb17a2ba69653c to your computer and use it in GitHub Desktop.
EnumerableEx, Enumerable Extension.
using System.Collections.Generic;
namespace Cores.Tools
{
public static class EnumerableEx
{
public static bool Unanimous<T>(this IEnumerable<T> enumerable)
{
using var enumerator = enumerable.GetEnumerator();
if (enumerator.MoveNext())
{
var current = enumerator.Current;
while (enumerator.MoveNext())
{
if (!Equals(current, enumerator.Current)) return false;
}
}
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment