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

推荐订阅源

Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Application and Cybersecurity Blog
Application and Cybersecurity Blog
AWS News Blog
AWS News Blog
GbyAI
GbyAI
腾讯CDC
WordPress大学
WordPress大学
V
V2EX
小众软件
小众软件
C
CXSECURITY Database RSS Feed - CXSecurity.com
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
H
Hacker News: Front Page
Scott Helme
Scott Helme
The Hacker News
The Hacker News
Schneier on Security
Schneier on Security
K
Kaspersky official blog
S
Security @ Cisco Blogs
N
News | PayPal Newsroom
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Threatpost
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Martin Fowler
Martin Fowler
P
Privacy International News Feed
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
O
OpenAI News
P
Proofpoint News Feed
J
Java Code Geeks
B
Blog RSS Feed
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
阮一峰的网络日志
阮一峰的网络日志
P
Palo Alto Networks Blog
Engineering at Meta
Engineering at Meta
AI
AI
Google DeepMind News
Google DeepMind News
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
Simon Willison's Weblog
Simon Willison's Weblog
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
G
GRAHAM CLULEY
A
Arctic Wolf
N
Netflix TechBlog - Medium
L
LINUX DO - 最新话题
爱范儿
爱范儿
博客园 - 聂微东

博客园 - 潘胜国

Emgu学习之(一)----Emgu简介 .NET 调用c++库注意事项 网站预编译命令说明(aspnet_compiler) VS2005即时窗口 DataSet主副表关系应注意的问题 通用验证脚本 SQL SERVER小Tips AG_E_RUNTIME_METHOD : CreateFromXaml错误的及解决 [转载]Converting a bitmap to a byte array 调试web服务器无法启动 IE 7 BETA 3安装 什么是爱情【转载】 取Assembly中的资源 利用IIS压缩文件 Page常用方法 IFame的另一种表现 自动提交问题,不知道这算不算是MS的一个BUG Ajax实现两级下拉框连动的应用 for和foreach的执行效率的问题之新发现
C# 2.0泛型初试
潘胜国 · 2005-10-31 · via 博客园 - 潘胜国

using System.Collections.Generic;
public class GenericList<T>
{
    // The nested class is also generic on T
    private class Node
    {
        // T used in non-generic constructor
        public Node(T t)
        {
            next = null;
            data = t;
        }

        private Node next;
        public Node Next
        {
            get { return next; }
            set { next = value; }
        }
       
        // T as private member data type
        private T data;

        // T as return type of property
        public T Data 
        {
            get { return data; }
            set { data = value; }
        }
    }

    private Node head;
   
    // constructor
    public GenericList()
    {
        head = null;
    }

    // T as method parameter type:
    public void AddHead(T t)
    {
        Node n = new Node(t);
        n.Next = head;
        head = n;
    }

    public IEnumerator<T> GetEnumerator()
    {
        Node current = head;

        while (current != null)
        {
            yield return current.Data;
            current = current.Next;
        }
    }
}
class TestGenericList
{
    static void Main()
    {
        // int is the type argument
        GenericList<string> list = new GenericList<string>();

        for (int x = 0; x < 10; x++)
        {
            list.AddHead(x.ToString()+"dsafl");
        }

        foreach (string i in list)
        {
            System.Console.Write(i + " ");
        }
        System.Console.WriteLine("\nDone");
    }
}