C# implements iterator pattern

C# implements iterator pattern

The iterator pattern is a common design pattern that allows us to access elements in a collection by traversing the collection. In the C# language, we can use the IEnumerable interface and the IEnumerator interface to implement the iterator pattern.

First define a Person class for storing personnel information:

public class Person
{
   
    
    
    public string Name {
   
    
     get; set; }
    public int Age {
   
    
     g

Guess you like

Origin blog.csdn.net/update7/article/details/132633107