摘要:
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 泛型接口{ public class GenericList<T> : System.Collections.Generic.IEnumerable<T> { //字段 protected Node head; protected Node current = null; //嵌套类 protected class Node { //字段 public Node next; private 阅读全文
摘要:
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 泛型委托{ delegate void StackEventHandler<T,U>(T sender,U eventArgs); //定义委托 //delegate void BinaryOp (int x, int y); //非泛型定义委托 class Stack<T> { public class StackEventArgs : EventArgs { } public even 阅读全文
摘要:
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 泛型_一__什么是泛型{ public class GenericList<T> { private class Node { //字段 private Node next; private T data; //有参构造函数 public Node(T t) { next = null; data = t; } //属性 next public Node Next { get { return nex 阅读全文
摘要:
yield关键字yield return 语句返回集合的一个元素,并移动到下一个元素上. yield break可停止迭代. using System; using System.Collection; namespace Wrox.ProCSharp.Arrays { public class HelloCollection { public IEnumerator GetEnumerator() { yield return "Hello"; yield return "World"; } } } 包含yield语句的方法或属性也称为迭代块.迭代块必 阅读全文