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

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - qqhe325

一个js游戏 向del.icio.us学习 lucene.net优化总结 Fxcop使用笔记 web service 记录1 自定义加密web.config实验记录 DTC:该伙伴事务管理器已经禁止了他对远程/网络事务的支持 C#基础- 抽象类,静态类 js自动加载日期类 img的onload事件 当图片路径超出网站根目录时 vs2005宏的问题 asp.net 2.0 access 未指定的错误 oledbparameter在update时出错不报错 grove 小例子 你试图打开的项目是Web项目,请指定URL路径 asp.net 在分析向此请求提供服务所需资源时出错 策略模式 我们是怎样的一代人[转]
delegate和event例子
qqhe325 · 2007-07-12 · via 博客园 - qqhe325

//delegate就是为了保证使用函数引用或叫函数指针时能检查函数类型
using
 System;namespace test1
{
    
/// <summary>
    
/// Class3 的摘要说明。
    
/// </summary>
    public delegate void calleventhandler(object sender,System.EventArgs e);
    
public delegate void calleventhandler2(string s);class telephone
    {
        
public telephone()
        {
            Console.WriteLine(
"客厅里有一个电话放在沙发上.");
        }
public event calleventhandler2 teleevent;public void someonecall()
        {
            Console.WriteLine (
"叔叔打电话过来要来打麻将。。。。");
            teleevent(
"abc");
        }        
    }
class sound
    {
        
public sound(){}public void ring(object sender,System.EventArgs e)
        {
            Console.WriteLine (
"电话铃响了.");
        }
public void ring2(string s)
        {
            Console.WriteLine (s
+"电话铃响了.");
        }
    }
class t{
    
public static void Main(){
        telephone t
=new telephone();
        sound s
=new sound();
       
        t.teleevent
+=new calleventhandler2(s.ring2);

        t.someonecall();
         }
    }

}

using System;namespace test2
{
public delegate void testhandler();class a{
        
public event testhandler eve;
        
public a(testhandler hand){
          eve
+=hand;
        }
public void run(){
           eve();
        }
    }
class c{
        
public static void c1(){
             Console.WriteLine (
"c1 is running");
         }
public static void c2()
        {
            Console.WriteLine (
"c2 is running");
        }
public static void c3()
        {
            Console.WriteLine (
"c3 is running");
        }
    }
class b{
        
public static void Main(){
            a A
=new a(new testhandler(c.c2));

            A.run();
        }
    }
}