Answers for "What is the yield keyword used for in C#?"

C#
0

What is the yield keyword used for in C#?

public void Consumer()
{
    foreach(int i in Integers())
    {
        Console.WriteLine(i.ToString());
    }
}

public IEnumerable<int> Integers()
{
    yield return 1;
    yield return 2;
    yield return 4;
    yield return 8;
    yield return 16;
    yield return 16777216;
}
Posted by: Guest on August-05-2021

Code answers related to "What is the yield keyword used for in C#?"

C# Answers by Framework

Browse Popular Code Answers by Language