return and yield return , break and yield break.

C# does not allow yield all by itself – only yield return and yield break.

yield is a contextual keyword that is only recognized inside iterator blocks and only in conjunction with either return or break.

One example case where yield-return is preferable is if the IEnumerable represents an infinite set. Consider the list of Prime Numbers, or an infinite list of random numbers. You can never return the full IEnumerable at once, so you use yield-return to return the list incrementally.
http://www.davidgiard.com/2009/09/13/YieldReturnAndYieldBreakInC.aspx

http://www.codeproject.com/Articles/38097/The-Mystery-Behind-Yield-Return

 

Advertisements
By Sriramjithendra Posted in C#.NET

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s