- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace IEnumerableTest
- {
- class Program
- {
- public static IEnumerable GetNextValue()
- {
- yield return "111111";
- yield return "222222";
- yield return "333333";
- yield return "444444";
- yield break;
- yield return "555555";
- }
- static void Main(string[] args)
- {
- Console.WriteLine("===迭代成员===");
- foreach (string item in GetNextValue())
- {
- Console.WriteLine(item);
- }
- Console.WriteLine("===迭代类===");
- Months months = new Months();
- foreach (string item in months)
- {
- Console.WriteLine(item);
- }
- Console.ReadKey();
- }
- }
- class Months : IEnumerable
- {
- string[] months = { "January","February","March","April","May","June","July","August","September","October","November","December"};
- public IEnumerator GetEnumerator()
- {
- for (int i = 0; i
关注打赏
热门博文
- Python:ULID通用唯一词典排序标识符
- Module not found: Error: Can‘t resolve ‘path‘
- 利用workflows工作流Actions自动部署Vue项目Deploy to GitHub Pages
- Vue2.js:前端在浏览器中网页表格打印的实现方案:window.print、print-js、iframe
- MacOS:使用内置的屏幕截图和屏幕录像功能
- css: Tailwind CSS一个功能类优先的 CSS 框架
- css:border-radius绘制边框圆角-全圆和椭圆
- PHP/Python/js:时间转为人类可读的字符串格式:刚刚、几分钟前、几小时前、几天前
- Golang:imaging一个简单、实用的图像处理工具
- element-plus:Dialog 对话框在有滚动条的页面会抖动
立即登录/注册


微信扫码登录