当前位置:网站首页>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!");
}
}
}
边栏推荐
- 【ManageEngine】IP地址扫描的作用
- Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
- 剑指Offer04. 二维数组中的查找【中等】
- How to convert a decimal number to binary in swift
- 4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
- Sword finger offer04 Search in two-dimensional array [medium]
- 基于Linu开发的项目视频
- TOGAF认证自学宝典V2.0
- Togaf certification self-study classic v2.0
- Public and private account sending prompt information (user microservice -- message microservice)
猜你喜欢

【数据库原理复习题】

Leetcode234 palindrome linked list

Application of ncnn neural network computing framework in orange school orangepi 3 lts development board

记录自己vulnhub闯关记录

(最新版) Wifi分销多开版+安装框架

自抗扰控制器七-二阶 LADRC-PLL 结构设计

Sword finger offer10- I. Fibonacci sequence

idea将web项目打包成war包并部署到服务器上运行

Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
![[review questions of database principles]](/img/c3/81d192a40bcc4f5d72fcbe76c708bb.png)
[review questions of database principles]
随机推荐
Sword finger offer09 Implementing queues with two stacks
启用MemCached的SASL认证
Enable SASL authentication for memcached
Ali & ant self developed IDE
Node. Js: use of express + MySQL
elastic_ L01_ summary
studio All flavors must now belong to a named flavor dimension. Learn more
Integer case study of packaging
ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
Powerful avatar making artifact wechat applet
Huffman coding experiment report
2021 autumn Information Security Experiment 1 (password and hiding technology)
写一个简单的nodejs脚本
Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board
Kung Fu pays off, and learning is done
4. 无线体内纳米网:电磁传播模型和传感器部署要点
记录自己vulnhub闯关记录
Using swift language features, write a pseudo-random number generator casually
initial、inherit、unset、revert和all的区别
Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'