2015年8月3日 星期一

[C#] IDictionaryEnumerator Extensions


public static class IDictionaryEnumeratorExtensions
    {
        /// <summary>
        /// Convert the IDictionaryEnumerator object to IEnumerable
        /// </summary>
        /// <param name="iter">IDictionaryEnumerator</param>
        /// <returns>IEnumerable</returns>
        public static IEnumerable<KeyValuePair<object, object>> ToEnumerable(this IDictionaryEnumerator iter)
        {
            using (iter as IDisposable)
            {
                while (iter.MoveNext()) yield return new KeyValuePair<object, object>(iter.Key, iter.Value);
            }
        }
    }

沒有留言:

張貼留言