当前位置:网站首页>C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: delegatesamplep245
C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: delegatesamplep245
2022-07-03 12:52:00 【superfreak】
using System;
// Define a delegate without return values and parameters
delegate void PrintFunction();
class Test
{
public void Print1()
{ Console.WriteLine("Print1---instance"); }
public static void Print2()
{ Console.WriteLine("Print2---static"); }
}
namespace Chapter13DelegateSampleP245
{
class Program
{
static void Main(string[] args)
{
Test t = new Test();// Create an instance of the test class
PrintFunction pf;// Create an empty delegate
pf = t.Print1;// Instantiate and initialize the delegate
// Add three additional methods to the delegate
pf += Test.Print2;
pf += t.Print1;
pf += Test.Print2;
// Now? There are four ways to delegate
if (null != pf)
pf();
else
Console.WriteLine("Delegate is empty!");
Console.WriteLine("Hello World!");
}
}
}
边栏推荐
- Differences and connections between final and static
- Swift return type is a function of function
- 强大的头像制作神器微信小程序
- Enable SASL authentication for memcached
- Keep learning swift
- 【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
- 阿里 & 蚂蚁自研 IDE
- Project video based on Linu development
- [network counting] Chapter 3 data link layer (2) flow control and reliable transmission, stop waiting protocol, backward n frame protocol (GBN), selective retransmission protocol (SR)
- 电压环对 PFC 系统性能影响分析
猜你喜欢
Day 1 of kotlin learning: simple built-in types of kotlin
Eureka自我保护
Sword finger offer06 Print linked list from end to end
基于同步坐标变换的谐波电流检测
【数据库原理及应用教程(第4版|微课版)陈志泊】【SQLServer2012综合练习】
Record your vulnhub breakthrough record
Quick learning 1.8 front and rear interfaces
Leetcode234 palindrome linked list
Social community forum app ultra-high appearance UI interface
Differences between initial, inherit, unset, revert and all
随机推荐
Ten workplace rules
双链笔记·思源笔记综合评测:优点、缺点、评价
GCN thinking - word2vec directly calculates text classification
studio All flavors must now belong to a named flavor dimension. Learn more
社交社区论坛APP超高颜值UI界面
Everything comes to him who waits
How to convert a decimal number to binary in swift
【習題七】【數據庫原理】
01_ Using the concurrent tool class library, is thread safety safe
Powerful avatar making artifact wechat applet
Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)
Node.js: express + MySQL的使用
【习题五】【数据库原理】
ORM use of node -serialize
Tensorflow binary installation & Failure
alright alright alright
Xctf mobile--app1 problem solving
写一个简单的nodejs脚本
Xctf mobile--rememberother problem solving
Deeply understand the mvcc mechanism of MySQL