Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Yield Statement
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Yield Statement
Miscellaneous
Thread ID:
01462394
Message ID:
01462394
Views:
122
I was looking at this:
http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx

Which seems to do the same as this:
List<int> Values = GetPowers(2, 8);
foreach (int i in Values)
{
    Console.Write("{0} ", i);
}


public static List<int> GetPowers(int number, int exponent)
{
    List<int> RetVal = new List<int>();

    int counter = 0;
    int result = 1;
    while (counter++ < exponent)
    {
        result = result * number;
        RetVal.Add(result);
    }

    return RetVal;
}
The yield statement calls into the Power methid repeatedly. This seems rather confusing to me, as apposed to my code above that
gets and returns all the values at once, the processes them.

I'd like to know what others think.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform