1.是否有子元素
public static bool HasElements(this ICollection items)
{
return items != null && items.Count > 0;
}
2.IsBetween
public static bool IsBetween<T>(this T value, T low, T high) where T : IComparable<T>
{
return value.CompareTo(low) >= 0 && value.CompareTo(high) <= 0;
}
3.each
public static void Each<T>(this ICollection<T> items, Action<T> action)
{
foreach (T item in items)
{
action(item);
}
}