zoukankan
html css js c++ java
简单的委托事件
class
1
using
System;
2
using
System.Collections.Generic;
3
4
namespace
ConsoleApplication3
5
{
6
/**/
///
<summary>
7
///
事件接受类
8
///
</summary>
9
class
Program
10
{
11
static
void
Main(
string
[] args)
12
{
13
EventSend es
=
new
EventSend();
14
es.myEvent
+=
new
EventSend.myDelegate(es_myEvent);
15
es.Run();
16
}
17
18
private
static
void
es_myEvent(
object
sender,MyEventArgs e)
19
{
20
//
事件处理方法
21
Console.WriteLine(
"
\n你触发了一次事件!\n你输入的是:
"
+
e.InputText);
22
}
23
}
24
/**/
///
<summary>
25
///
事件发送类
26
///
</summary>
27
class
EventSend
28
{
29
public
delegate
void
myDelegate(
object
sender, MyEventArgs e);
//
定义委托
30
public
event
myDelegate myEvent;
//
定义委托类型的事件
31
public
void
Run()
32
{
33
while
(
true
)
34
{
35
Console.BackgroundColor
=
ConsoleColor.Red;
36
Console.ForegroundColor
=
ConsoleColor.Yellow;
37
Console.WriteLine(
"
=== 退出请选择 n 或 N ===
"
);
38
MyEventArgs e1
=
new
MyEventArgs();
39
e1.InputText
=
Console.ReadLine();
40
string
str
=
e1.InputText;
41
if
(str
==
"
n
"
||
str
==
"
N
"
)
42
{
43
break
;
44
}
45
myEvent(
this
, e1);
46
}
47
}
48
}
49
50
/**/
///
<summary>
51
///
事件的内容
52
///
</summary>
53
class
MyEventArgs:EventArgs
54
{
55
private
string
inputText;
56
public
string
InputText
57
{
58
get
59
{
60
return
this
.inputText;
61
}
62
set
63
{
64
this
.inputText
=
value;
65
}
66
}
67
}
68
}
69
每天进步一点点...
查看全文
相关阅读:
POJ 最小球覆盖 模拟退火
POJ 1379 模拟退火
PythonTip(2)
PythonTip(1)
LA 3353 最优巴士线路设计
LA 4254 贪心
判断分析
因子分析——因子得分
因子分析——应用
因子分析——因子旋转
原文地址:https://www.cnblogs.com/cyan/p/1287381.html
最新文章
记一次网页超时登录的Bug
vue2.0中使用pug(jade)
vue2.0中使用less
vue2.0中使用sass
搭建Zookeepeer源码工程
CSU计算机研究生推免
牛客练习赛20(ABC)
高通Vuforia
塔防cocos2d
推箱子Unity
热门文章
关于APIT定位算法的讨论
中南大学夏令营集训营
codeforces 676C
确定性时间序列
神经网络应用
神经网络理论
TSP 遗传算法
Codeforces Round #460 (Div. 2)
Matlab Colour Theme
TSP 模拟退火
Copyright © 2011-2022 走看看