`
sabolasi
  • 浏览: 903675 次
文章分类
社区版块
存档分类
最新评论

Events Sample Code(1)

 
阅读更多

using System;

namespace ConsoleApp_CS
{

class 小弟
{
//1.聲明事件實例
public event EventHandler 挨扁;

//2.包含事件
private void 挨扁了(EventArgs e)
{
if(this.挨扁 != null)
this.挨扁(this, e);
}

//3.觸發事件
public void 被扁()
{
Console.WriteLine("被扁ing...");
this.挨扁了(EventArgs.Empty);
}
}

class 我
{
private 小弟 我小弟 = null;

public 我(小弟 小小弟)
{
this.我小弟 = 小小弟;

//註冊事件
this.我小弟.挨扁 += new EventHandler(this.担心);
}

public void 担心(object sender, EventArgs e)
{
Console.WriteLine("我担心");
}
}

class InstanceDelegate
{
[STAThread]
public static void Main ()
{
小弟 小弟弟 = new 小弟();
我 大哥 = new 我(小弟弟);
小弟弟.被扁();
Console.ReadLine();
} //end of main
}
}

分享到:
评论

相关推荐

    WMI ACPI Sample

    The WMIACPI sample contains ACPI BIOS and Microsoft Windows Management Instrumentation (WMI) sample code that enables instrumentation of the ACPI BIOS from within ACPI Source Language (ASL) code....

    C++ 示例演示使用 COM 的事件处理

    ComEvents EventReceiver ...This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.

    Android代码-sample-of-Android-week-view

    This is a sample of android week view,Thanks the author of android week view ,The WeekHeaderView is based on android week view .This project contains two view ,the header view and day view.You can add...

    xdma_driver_win_src_2018_2.zip (xilinx pcie dma driver)

    | |__ user_events/ - Sample code for access to user event interrupts. | |__ xdma_info/ - Utility application which prints out the XDMA core ip | | configuration. | |__ xdma_rw/ - Utility for reading...

    ShellBrowser.v2.5.For.Delphi4567.BCB456

    A thumbnail component displays the Explorer thumbnailimages and the TJamShellNotifier informs you about numerous shell events.Interesting sample projects and help file with a lot of sample code are...

    ShellBrowser v3.2 for Delphi BCB

    A thumbnail component displays the Explorer thumbnail images and the amShellNotifier informs you about numerous shell events.Interesting sample projects and help file with a lot of sample code are ...

    Automating Microsoft Office 97 and Microsoft Office 2000

    讲述了自动化Office组件的基本知识和方法,是自动化Office组件的入门之作. ...10 Sample Code for Automating Microsoft Office Applications 11 Troubleshooting Common Problems 12 For More Information

    SwingLayouts_Components_SampleCode.zip_Java编程_Java_

    几个基础java swing示例,包括不同的layout和events

    Shellbrowser Component Suite v7.3

    The TJamShellList, TJamShellTree and ... Interesting sample projects and a help file with a lot of sample code are included. The ShellBrowser Delphi Edition is royalty free and involves no runtime fees.

    get-code-scanning-alerts-in-org-sample:此仓库演示了如何使用GitHub Code Scanning API将组织中的所有警报导出到CSV文件

    创建一个具有repo > security_events权限的。 ( repo许可需要私人回购) 如GH_AUTH_TOKEN=inserttokenhere所示,将令牌添加到您的.env文件。 运行npm install安装节点依赖项 运行node get-code-scanning-alerts....

    Packt.Learn.Node.js.by.Building.6.Projects代码

    We're going to take the sample code from the Node.js website and expand on that. Chapter 2, A Basic Express Website, will be a basic Express website where we'll introduce the Express server. Chapter ...

    Bayesian Network(贝叶斯网络) Python Program

    It could include code to generate events (rather than read them from a file). And it could include code to describe more clearly what is going on whenever a node's probability is updated (e.g., what ...

    iOS 5 Programming Cookbook Solutions & Examples for iPhone, iPad

    Each recipe provides a clear solution with sample code that you can use right away. Use different approaches to construct a user interface Develop location-aware apps Get working examples for ...

    iOS 6 Programming Cookbook

    Each recipe includes sample code you can use right away. Define the layout of UI elements with Cocoa Auto Layout Develop location-aware apps Get working examples for implementing gesture recognizers ...

    ShellBrowser Full Sources For Delphi BCB

    The ShellBrowser component set gives a Delphiprogrammer easy access to the Win32 shellfunctionality.... Interesting sample projects andhelp file with a lot of sample code areincluded.

    linux_system_administration

    Linux and Unix and related technologies, including sample chapters and code examples. ONLamp.com is the premier site for the open source web platform: Linux, Apache, MySQL and either Perl, Python, or ...

    events-graphql-codegen-example:示例项目展示了类型化组件在React和GraphQL中的使用

    介绍这是一个Starter React应用程序,用于在构建GraphQL API时在AWS AppSync控制台中使用Sample应用程序。 Sample应用程序创建一个GraphQL模式并置备Amazon DynamoDB资源,然后将它们与解析器适当地连接。 该应用...

    Learning jQuery 3 - Fifth Edition

    we'll discover how to use the newly introduced JavaScript promises and the new animation API in jQuery 3.0 in great detail, along with sample code and examples. By the end of the book, you will be ...

    Professional C# 3rd Edition

    Part I: The C# Language 1 Chapter 1: .NET Architecture 3 The Relationship of C# to .NET 4 The Common Language Runtime 4 Advantages of Managed Code 4 A Closer Look at Intermediate Language 7 Support ...

    PLX PCI卡 linux驱动

    Please refer to the source code in each sample & the PLX SDK User's Manual for additional details. The PLX samples are intended to demonstrate use of the PLX API. The samples are not intended for ...

Global site tag (gtag.js) - Google Analytics