public class Weeks : System.Collections.IEnumerable
    {

        private string[] _weeks = new string[] { "", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };


        #region IEnumerable 成员

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            foreach (string str in _weeks)
            {
                yield return str;                 //yield  关键字用于指定返回的一个或多个值。到达 yield return 语句时,会保存当前位置。下次调用迭代器时将从此位置重新开始执行。
            }
        }

        #endregion
    }

相关文章:

  • 2021-09-24
  • 2021-06-03
  • 2022-12-23
  • 2021-06-30
  • 2021-11-28
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-21
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案