yield grammar

public static IEnumerable<T> Batch<T>(this IEnumerable values, T emptyVaue)
        {
            if (values.IsNullOrEmpty())
            {
                yield break;
            }
            foreach (object objItem in values)
            {
                yield return objItem.XXX<T>(emptyVaue);
            }            
        }

Key words:yield break;

From:  http://stackoverflow.com/questions/497780/whats-the-use-of-yield-break

原文地址:https://www.cnblogs.com/yanyuge/p/2873350.html