-
July 3rd, 2013, 10:21 AM
#1
A question regarding yield break and yield return
Here is an article explaining how to use yield break and yield return, http://iserialized.com/a-quick-start...d-yield-break/
In the article, there is a method without using yield,
Code:
public static List<int> GetResultList()
{
var l = new List<int>();
for (int i = 0; i < 100; i++)
{
l.Add(i);
}
return l;
}
And also there is another method using yield,
Code:
public static IEnumerable<int> GetResult()
{
for (int i = 0; i < 100; i++)
{
yield return i;
}
}
My question what GetResult does? Does it achieve the same thing as GetResultList? Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|