1、WindowsLiveWriter.CNBlogs.CodeHighlighter
/// /// 遍历元素
/// /// /// /// /// public static IEnumerable ForEach (this IEnumerable source, Action action) { if (source == null) { throw new ArgumentNullException("source"); } if (action == null) { throw new ArgumentNullException("action"); } foreach (var item in source) { action(item); yield return item; } }
2、Windows Live Writer Source Code plugin for SyntaxHighlighter
////// 将集合分段 /// 指定每段的长度range /// ////// /// /// public static IEnumerable > Subparagraph (this IEnumerable source, int rangelength) { if (rangelength < 1) { throw new Exception("rangelength参数应大于等于1"); } if (source == null) { throw new ArgumentNullException("source"); } var temp = source; while (!temp.IsEmpty()) { yield return temp.Take(rangelength); temp = temp.Skip(rangelength); } }