在扩展方法中使用 yield 运算符是线程安全的吗?
例如:
public static IEnumerable<CartItem> GetItems( this Cart cart )
{
{
while( cart.hasNext() )
yield return cart.GetNextItem( );
}
}
在扩展方法中使用 yield 运算符是线程安全的吗?
例如:
public static IEnumerable<CartItem> GetItems( this Cart cart )
{
{
while( cart.hasNext() )
yield return cart.GetNextItem( );
}
}