Use delegate: event : delegate Event « Language Basics « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Class Interface
3. Collections Data Structure
4. Components
5. Data Types
6. Database ADO.net
7. Design Patterns
8. Development Class
9. Event
10. File Stream
11. Generics
12. GUI Windows Form
13. Language Basics
14. LINQ
15. Network
16. Office
17. Reflection
18. Regular Expressions
19. Security
20. Services Event
21. Thread
22. Web Services
23. Windows
24. XML
25. XML LINQ
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / C Sharp » Language Basics » delegate EventScreenshots 
Use delegate: event
Use delegate: event

/*
 * C# Programmers Pocket Consultant
 * Author: Gregory S. MacBeth
 * Email: gmacbeth@comporium.net
 * Create Date: June 27, 2003
 * Last Modified Date:
 */
using System;

namespace Client.Chapter_8___Delegates_and_Events
{
  public delegate void MyDelegateEventHandler(int i);
  
  public class MyEventSubscriberChapter_8___Delegates_and_Events
  {
    static void Main(string[] args)
    {
      MyEventPublisher EventPublisher = new MyEventPublisher();
      

      MyDelegateEventHandler MyAnonymousDelegate = delegate(int x)
      {
        Console.WriteLine("Anonymous Event FIRED!");
      };

      EventPublisher.MyEvent += MyAnonymousDelegate;
      
      EventPublisher.DoSomething();
    }
    
  }
  
  public class MyEventPublisher
  {
    public event MyDelegateEventHandler MyEvent;
    public int DoSomething()
    {
      MyEvent(5);
      return 0;
    }
  }

}

           
       
Related examples in the same category
1. A very simple event demonstrationA very simple event demonstration
2. An event multicast demonstrationAn event multicast demonstration
3. Individual objects receive notifications when instance event handlers are usedIndividual objects receive notifications when instance 
   event handlers are used
4. A class receives the notification when a static method is used as an event handlerA class receives the notification when  
   a static method is used as an event handler
5. Create a custom means of managing the event invocation listCreate a custom means of managing the event invocation list
6. Use the bult-in EventHandler delegateUse the bult-in EventHandler delegate
7. Delegate and event hierarchyDelegate and event hierarchy
8. Events:Add and Remove FunctionsEvents:Add and Remove Functions
9. Events:Add and Remove Functions 2Events:Add and Remove Functions 2
10. Events: Custom Add and RemoveEvents: Custom Add and Remove
11. Delegates And EventsDelegates And Events
12. Delegates And Events 2Delegates And Events 2
13. Chaining events.
w__ww_._ja_v_a__2_s_.__co_m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.