当前位置:网站首页>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!");
}
}
}
边栏推荐
- 剑指Offer06. 从尾到头打印链表
- Dix règles de travail
- 低代码平台国际化多语言(i18n)技术方案
- 基于同步坐标变换的谐波电流检测
- Define a list, store n integers, and calculate the length, maximum value, minimum value and average value of the list
- [ArcGIS user defined script tool] vector file generates expanded rectangular face elements
- Sword finger offer06 Print linked list from end to end
- alright alright alright
- Analysis of a music player Login Protocol
- Powerful avatar making artifact wechat applet
猜你喜欢

Social community forum app ultra-high appearance UI interface

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

Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward

强大的头像制作神器微信小程序

Huffman coding experiment report

阿里大于发送短信(用户微服务--消息微服务)

Xctf mobile--rememberother problem solving

Sword finger offer14 the easiest way to cut rope

ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍

Four problems and isolation level of MySQL concurrency
随机推荐
[comprehensive question] [Database Principle]
[problem exploration and solution of one or more filters or listeners failing to start]
剑指Offer03. 数组中重复的数字【简单】
Sword finger offer03 Repeated numbers in the array [simple]
elastic_ L01_ summary
Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
【数据挖掘复习题】
Nodejs+Express+MySQL实现登陆功能(含验证码)
Define a list, store n integers, and calculate the length, maximum value, minimum value and average value of the list
Swift return type is a function of function
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)
Public and private account sending prompt information (user microservice -- message microservice)
ORM use of node -serialize
Method overloading and rewriting
Do you feel like you've learned something and forgotten it?
02_ Lock the code, and don't let the "lock" become a worry
Simple use and precautions of kotlin's array array and set list
Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
(最新版) Wifi分销多开版+安装框架