Is thread-safe to use the 'yield' operator inside an extension method'?

Posted by SDReyes on Stack Overflow See other posts from Stack Overflow or by SDReyes
Published on 2010-04-23T23:25:07Z Indexed on 2010/04/23 23:43 UTC
Read the original article Hit count: 197

Filed under:
|
|
|
|

Would be thread-safe to use the yield operator inside an extension method?

For example:

public static CartItem GetItems( this Cart cart )
{
        {
            while( cart.hasNext() )
                yield return cart.GetNextItem( );
        }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET