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

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - 小乔的闺房

学习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;
    }
}