您现在的位置是:主页 > news > 男人女人做邪恶的事网站/seo专业培训需要多久

男人女人做邪恶的事网站/seo专业培训需要多久

admin2025/5/13 6:37:29news

简介男人女人做邪恶的事网站,seo专业培训需要多久,网站建设教程金旭亮,bloom wordpress1.why IteratorsC#中的foreach语句用于迭代一个可枚举集合的元素.为了实现可枚举,这个集合元素必须实现无参的GetEnumerator 方法,该方法返回一个enumerator,通常情况下enumerator实现起来是比较困难的,用Iterators让这个任务变得非常简单.2.How Iterators一个iterator 是yield…

男人女人做邪恶的事网站,seo专业培训需要多久,网站建设教程金旭亮,bloom wordpress1.why IteratorsC#中的foreach语句用于迭代一个可枚举集合的元素.为了实现可枚举,这个集合元素必须实现无参的GetEnumerator 方法,该方法返回一个enumerator,通常情况下enumerator实现起来是比较困难的,用Iterators让这个任务变得非常简单.2.How Iterators一个iterator 是yield…
1.why Iterators
C#中的foreach语句用于迭代一个可枚举集合的元素.为了实现可枚举,这个集合元素必须实现无参的GetEnumerator 方法,该方法返回一个enumerator,通常情况下enumerator实现起来是比较困难的,用Iterators让这个任务变得非常简单.
2.How Iterators
一个iterator 是yields一个有序值序列的语句块.一个iterator 不同于其他语句块的地方在于它有一个或多个yield语句
a. yield return 语句用于产生迭代的下一个值
b.yield break语句表示迭代完成.
一个iterator 可以用做一个函数的函数体,只要这个函数的返回值类型是enumerator interfaces 或者enumerable interfaces.
a.enumerator interfaces 是System.Collections.IEnumerator 或者是范型System.Collections.Generic.IEnumerator<T>的构造类型.
b.enumerable interfaces是System.Collections.IEnumerable 或者是范型System.Collections.Generic.IEnumerable<T>的构造类型.
理解一下一点是非常重要的:iterator 不是一个成员而是实现函数成员的手段.一个通过iterator 实现的方法,可以被其他成员overridden或者overloaded(这不知道这两个单词怎么翻译了,很多翻译都把这两个单词处理为重载,这是不太欠当的,因为两者不是一回事,直接用E文好了),那些成员可以用iterator 实现也可以不用iterator 实现.
下面的例子是Stack<T>用iterator实现它的Enumerator.iterator从栈顶到栈底枚举栈中的元素
None.gifusing System.Collections.Generic;
None.gif
None.gif
public class Stack<T>: IEnumerable<T>
None.gif
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
InBlock.gif    T[] items;
InBlock.gif
InBlock.gif    
int count;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
public void Push(T data) dot.gif{dot.gif}
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
public T Pop() dot.gif{dot.gif}
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
public IEnumerator<T> GetEnumerator() dot.gif{
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
for (int i = count – 1; i >= 0--i) dot.gif{
InBlock.gif
InBlock.gif           yield 
return items[i];
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedBlockEnd.gif}

None.gif
方法GetEnumerator是Stack<T>变成一个可以枚举的类型.下面的例子展现了如何用foreach来列举栈中的成员.
None.gifusing System;
None.gif
None.gif
class Test
None.gif
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
static void Main() dot.gif{
InBlock.gif
InBlock.gif        Stack
<int> stack = new Stack<int>();
InBlock.gif
InBlock.gif        
for (int i = 0; i < 10; i++) stack.Push(i);
InBlock.gif
InBlock.gif        
foreach (int i in stack) Console.Write("{0} ", i);
InBlock.gif
InBlock.gif        Console.WriteLine();
InBlock.gif
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedBlockEnd.gif}

None.gif

转载于:https://www.cnblogs.com/Farseer1215/archive/2005/11/27/285480.html