Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MulticastDelegate.cs
Package: CSharpprogramming.rar [view]
Upload User: lxycoco
Upload Date: 2022-07-21
Package Size: 38457k
Code Size: 1k
Category:
CSharp
Development Platform:
Others
- using System;
- namespace MulticastDelegate
- {
- delegate void DoubleOp(double value);
- class MainEntryPoint
- {
- static void Main()
- {
- DoubleOp operations = new DoubleOp(MathsOperations.MultiplyByTwo);
- operations += new DoubleOp(MathsOperations.Square);
- ProcessAndDisplayNumber(operations, 2.0);
- ProcessAndDisplayNumber(operations, 7.94);
- ProcessAndDisplayNumber(operations, 1.414);
- Console.WriteLine();
- Console.ReadLine();
- }
- static void ProcessAndDisplayNumber(DoubleOp action, double value)
- {
- Console.WriteLine("nProcessAndDisplayNumber called with value = " + value);
- action(value);
- }
- }
- class MathsOperations
- {
- public static void MultiplyByTwo(double value)
- {
- double result = value*2;
- Console.WriteLine("Multiplying by 2: {0} gives {1}", value, result);
- }
- public static void Square(double value)
- {
- double result = value*value;
- Console.WriteLine("Squaring: {0} gives {1}", value, result);
- }
- }
- }