Use Yield Instead of a List in C# for Iterations on Collections October 21, 2019 You can use the yield keyword to hold and return the data to the caller. See below for an example. Public static IEnumerable ExampleMethod(){ List li = new List(); foreach