惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Martin Fowler
Martin Fowler
G
Google Developers Blog
F
Fortinet All Blogs
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Tailwind CSS Blog
Cloudbric
Cloudbric
U
Unit 42
MyScale Blog
MyScale Blog
TaoSecurity Blog
TaoSecurity Blog
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美
博客园 - Franky
AI
AI
爱范儿
爱范儿
L
LangChain Blog
小众软件
小众软件
D
DataBreaches.Net
M
MIT News - Artificial intelligence
GbyAI
GbyAI
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Cloudflare Blog
Help Net Security
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy International News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Docker
A
About on SuperTechFans
Scott Helme
Scott Helme
The GitHub Blog
The GitHub Blog
V
V2EX
N
Netflix TechBlog - Medium
S
Security Affairs
Security Archives - TechRepublic
Security Archives - TechRepublic
H
Heimdal Security Blog
WordPress大学
WordPress大学

博客园 - 小乔的闺房

学习ID,ClientID,UniqueID 基础知识1 (2)最简单的Remoting程序 (1)将对象序列化为bin,soap,xml (3)集合接口 (1)学习数组,集合,IEnumerable接口,引申学习迭代器 (2)学习集合,引申学习索引器和泛型 自定义服务器控件(1)整体把握(未完待续) FindControl实现原理 location详解 使用ASP.NET AJAX实现(图片)幻灯片效果 固定GridView列字符串长度,多于的用...代替 读取Excel数据到GridView相关问题(待完善) 说明nchar(10),char(10),nvarchar(10),varchar(10) syscolumns 获得数据库里所有表的名称 类[属性扩展],属性[属性扩展](待完善) 获得数据库表的列数 WebForm里弹出警告框之内的自定义类MessageBox
(4)迭代器
小乔的闺房 · 2007-11-02 · via 博客园 - 小乔的闺房

1. 为什么要使用迭代器,它的由来,请见(1)学习数组,集合,IEnumerable接口,引申学习迭代器

2. 规则
2.1 迭代器是可以返回相同类型的值的有序序列的一段代码.
2.2 迭代器可用作方法,运算符或get访问器的代码体.
2.3 迭代器代码使用yield return语句依次返回每个元素.yield break将终止迭代.
2.4 可以在类中实现多个迭代器.每个迭代器都必须像任何类成员一样有唯一的名称,并且可以在foreach语句中被客户端代码调用,如下所示:foreach(int x in SampleClass.Iterator2){}
2.5 迭代器的返回类型必须为IEnumerable,IEnumerator,IEnumerable<T>或IEnumerator<T>.

3. 下面尽可能多的举使用迭代器的例子,加深理解
例2.1
protected void Page_Load(object sender, EventArgs e)
{
    foreach (int iResult in Power(2, 8))
    {
        lblName.Text += iResult.ToString() + ",";
    }
}

//求幂 iNumber数 iExponent指数
public static IEnumerable Power(int iNumber, int iExponent)
{
    int iCounter = 0;
    int iResult = 1;
    while (iCounter++ < iExponent)
    {
        iResult = iResult * iNumber;
        yield return iResult;
    }
}