-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1277 lines (637 loc) · 41.1 KB
/
index.html
File metadata and controls
1277 lines (637 loc) · 41.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html class="theme-next mist use-motion">
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?3621c3210fc2eba7c8f9aff7bbbb85d1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />
<meta name="keywords" content="Hexo, NexT" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />
<meta name="description" content="So, i can say "That's easy."">
<meta property="og:type" content="website">
<meta property="og:title" content="Blog">
<meta property="og:url" content="http://ea5y.coding.me/index.html">
<meta property="og:site_name" content="Blog">
<meta property="og:description" content="So, i can say "That's easy."">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Blog">
<meta name="twitter:description" content="So, i can say "That's easy."">
<script type="text/javascript" id="hexo.configuration">
var NexT = window.NexT || {};
var CONFIG = {
scheme: 'Mist',
sidebar: {"position":"left","display":"post"},
fancybox: true,
motion: true,
duoshuo: {
userId: 0,
author: '博主'
}
};
</script>
<title> Blog </title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?3621c3210fc2eba7c8f9aff7bbbb85d1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<div class="container one-collumn sidebar-position-left
page-home
">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-meta custom-logo">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Blog</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle">Debug.Log("if i have a drawback,i will show,just like as if this is a exception,should be show,")</p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
首页
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />
分类
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
归档
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
标签
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/11/13/C Sharp/IEnumerator/" itemprop="url">
IEnumerator和IEnumerable 越看越懵
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-11-13T22:32:00+08:00" content="2016-11-13">
2016-11-13
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/C/" itemprop="url" rel="index">
<span itemprop="name">C#</span>
</a>
</span>
</span>
<span class="post-comments-count">
|
<a href="/2016/11/13/C Sharp/IEnumerator/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2016/11/13/C Sharp/IEnumerator/" itemprop="commentsCount"></span>
</a>
</span>
<span id="/2016/11/13/C Sharp/IEnumerator/" class="leancloud_visitors" data-flag-title="IEnumerator和IEnumerable 越看越懵">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h3 id="IEnumerator-IEnumerable-越看越懵"><a href="#IEnumerator-IEnumerable-越看越懵" class="headerlink" title="IEnumerator IEnumerable 越看越懵"></a>IEnumerator IEnumerable 越看越懵</h3><p>刚接触IEnumerator的地方是在unity中有个叫协程的东西,基本作用就是执行这个协程函数,可以控制上一个表达式到下一个表达式之间的时间间隔,看到这里,觉得相当简单,用着也特舒服。但是,当我在项目中,看到大量的IEnumerator,然后又没有调用unity的协程的时候,我就傻逼了,不知道怎么办了。基于我目前对他的理解,我写下这篇博文,希望有大大可以给我指点指点。非常感谢。</p>
<h4 id="枚举器"><a href="#枚举器" class="headerlink" title="枚举器"></a>枚举器</h4><p>继承IEnumerator的类就叫做枚举器。<br>它包含:<br>MoveNext()方法<br>current属性</p>
<h4 id="可枚举类"><a href="#可枚举类" class="headerlink" title="可枚举类"></a>可枚举类</h4><p>继承IEnumerable的类就叫做可枚举类。可枚举类,都会包含一个GetEnumerator()方法,该方法会返回一个枚举器,就是上面提到的。</p>
<h4 id="小结"><a href="#小结" class="headerlink" title="小结"></a>小结</h4><p>枚举器和可枚举类的关系呢,好比是:一个人拿着一个计算器,就能方便的计算。可枚举类就是人,枚举器就是计算器,GetEnumerator()方法就是手,所以我们想要快速方便的进行计算,人,手,计算器,缺一不可。<br>话又说回来,为什么会有这两个东西。因为有一个foreach遍历,之所以foreach可以对数组进行遍历,就是因为数组是一个可枚举类,它通过一个GetEnumerator()方法,获得一个枚举器。枚举器有个current属性,代表当前值,有一个MoveNext()方法,用于遍历,当执行MoveNext(),current就往下走,代表下一个值,当下一个值存在的时候,MoveNext()返回true,否则返回false.</p>
<h4 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">1.获取枚举器</div><div class="line">IEnumerator ie = Array.GetEnumerator();</div><div class="line">2.通过ie.MoveNext()遍历</div><div class="line">while(ie.MoveNext())//返回true,表示存在</div><div class="line">{</div><div class="line"> 3.通过current取值</div><div class="line"> int i = (int)ie.current;//current类型为object,可转换为任何类型</div><div class="line">}</div></pre></td></tr></table></figure>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/11/13/C Sharp/接口/" itemprop="url">
接口
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-11-13T22:09:00+08:00" content="2016-11-13">
2016-11-13
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/C/" itemprop="url" rel="index">
<span itemprop="name">C#</span>
</a>
</span>
</span>
<span class="post-comments-count">
|
<a href="/2016/11/13/C Sharp/接口/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2016/11/13/C Sharp/接口/" itemprop="commentsCount"></span>
</a>
</span>
<span id="/2016/11/13/C Sharp/接口/" class="leancloud_visitors" data-flag-title="接口">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h3 id="接口:"><a href="#接口:" class="headerlink" title="接口:"></a>接口:</h3><p>指定一组函数成员而不实现它们,是一种引用类型。只能类和结构来实现接口。</p>
<h4 id="最直观的体现:"><a href="#最直观的体现:" class="headerlink" title="最直观的体现:"></a>最直观的体现:</h4><p>我定义了一个函数,参数是类A,所以,理所当然,函数的功能类A可以实现,而当我们传入类B时,就不能实现了。而在这个时候,如果我们定义函数时,用的参数时一个接口的引用IO,只要类A和类B都实现了接口IO,那么这个函数就能实现这两个类的功能。</p>
<h4 id="接口是引用类型:"><a href="#接口是引用类型:" class="headerlink" title="接口是引用类型:"></a>接口是引用类型:</h4><p>我们不能直接通过类对象的成员访问接口,我们可以通过强制转换类型来获取指向接口的引用。有了引用,就可以使用接口引用来调用方法了。</p>
<h4 id="as运算符:"><a href="#as运算符:" class="headerlink" title="as运算符:"></a>as运算符:</h4><p>通过as运算符,可以很好的获取接口的引用。<br> IO io = A as IO<br>如果类A继承接口,则io != null,否则 io == null,所以as有两个步骤:1.转换。 2.检测。</p>
<h4 id="实现多个接口:"><a href="#实现多个接口:" class="headerlink" title="实现多个接口:"></a>实现多个接口:</h4><p>原来一样,实现对应的定义即可。</p>
<h4 id="实现有重复成员的接口:"><a href="#实现有重复成员的接口:" class="headerlink" title="实现有重复成员的接口:"></a>实现有重复成员的接口:</h4><p>完全相同的成员,在类中实现一个即可。</p>
<h4 id="多个接口的引用:"><a href="#多个接口的引用:" class="headerlink" title="多个接口的引用:"></a>多个接口的引用:</h4><p>用as获取单个接口的引用。</p>
<h4 id="接口可以继承接口:"><a href="#接口可以继承接口:" class="headerlink" title="接口可以继承接口:"></a>接口可以继承接口:</h4><p>继承该接口的类,同样要实现所有接口成员。</p>
<h4 id="基类继承并实现了接口,派生成员也可引用"><a href="#基类继承并实现了接口,派生成员也可引用" class="headerlink" title="基类继承并实现了接口,派生成员也可引用"></a>基类继承并实现了接口,派生成员也可引用</h4>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/10/18/Design Mode/The MVC Design Mode/" itemprop="url">
MVC Design Mode
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-10-18T21:46:00+08:00" content="2016-10-18">
2016-10-18
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/Design-Mode/" itemprop="url" rel="index">
<span itemprop="name">Design Mode</span>
</a>
</span>
</span>
<span class="post-comments-count">
|
<a href="/2016/10/18/Design Mode/The MVC Design Mode/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2016/10/18/Design Mode/The MVC Design Mode/" itemprop="commentsCount"></span>
</a>
</span>
<span id="/2016/10/18/Design Mode/The MVC Design Mode/" class="leancloud_visitors" data-flag-title="MVC Design Mode">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><code> </code>this is my first time meet the MVC in the project.before then,i have leran the design mode.even so,i has not learn the soul of the design mode.perhaps,i don’t know the interface.this time,i not only understand the MVC, but also know what is the interface,and how to use the interface.because this blog is about the design mode,i will not say the interface.but i will write it in another blog. first,when we write the logic code about project’s UI.we will write something about the view and change the display of view.if we want to change it,should get the data.so we do three things:</p>
<pre><code>1. display view.
2. get data.
3. change the display of view.
</code></pre><h3 id="View"><a href="#View" class="headerlink" title="View"></a>View</h3><p><code> </code>now real charactor appearances, i can write a class about view who responsibles for two things:</p>
<pre><code>1. display the view.
2. given the interface about how to change the view.
</code></pre><p><code> </code>so we get the two: View.cs,IView.cs (Ps:i will use the c sharp to description.)</p>
<h3 id="Model"><a href="#Model" class="headerlink" title="Model"></a>Model</h3><p><code> </code>then,i can write the second class about model who responsibles for three things:</p>
<pre><code>1. change the data.
2. get the data.
3. given the interface bout how to get and change the model.
</code></pre><p><code> </code>in there,i can add a observer to monitor the change of model.when the data in model is changed,he will send a event message,if somewhere accept the message,then can call the function who was registed.so we get two too: Model.cs,IModel.cs</p>
<h3 id="Controller"><a href="#Controller" class="headerlink" title="Controller"></a>Controller</h3><p><code> </code>and there is a controller need to be done.the controller responses three things:</p>
<pre><code>1. add view event.
2. change model.
3. change the display by model.
</code></pre><p><code> </code>so we get one: Controller.cs</p>
<p><code> </code>We’d better have a manager to controller the panel’s jump,the one who manage all panels, or manage a system of all panels.</p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/10/17/C Sharp/How to use the generic paradigm of EventHandler/" itemprop="url">
How to use the EventHandler<T>
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-10-17T22:44:00+08:00" content="2016-10-17">
2016-10-17
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/C-Sharp/" itemprop="url" rel="index">
<span itemprop="name">C Sharp</span>
</a>
</span>
</span>
<span class="post-comments-count">
|
<a href="/2016/10/17/C Sharp/How to use the generic paradigm of EventHandler/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2016/10/17/C Sharp/How to use the generic paradigm of EventHandler/" itemprop="commentsCount"></span>
</a>
</span>
<span id="/2016/10/17/C Sharp/How to use the generic paradigm of EventHandler/" class="leancloud_visitors" data-flag-title="How to use the EventHandler<T>">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p> today when i saw the code about our project,i discover the EventHandler<t> delegate.it’s so fun.we can define a customer class who inherits from EventArgs,we can do somethings about change the value in this class.then we declare an event of delegate type EventHandler of my customer class,when my value changed will send an event message,if somewhere accept the message,will call the function that’s registed to the event.<br> there is a quesion why my class should inherits from EventArgs?<br> because delegate type EventHandler<t> has two params(object, EventArgs),we must send an EventArgs param.<br> 1.define a class who inherits from EventArg<br> 2.declare an event<br> 3.regist an event<br> 4.trriger the event when our value changed<br><figure class="highlight cs"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">using</span> System;</div><div class="line"><span class="keyword">using</span> System.Collections.Generic;</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title">MyEventArgs</span> : <span class="title">EventArgs</span></div><div class="line">{</div><div class="line"> <span class="keyword">private</span> <span class="keyword">string</span> msg;</div><div class="line"></div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="title">MyEventArgs</span>(<span class="params"> <span class="keyword">string</span> messageData </span>) </span>{</div><div class="line"> msg = messageData;</div><div class="line"> }</div><div class="line"> <span class="keyword">public</span> <span class="keyword">string</span> Message { </div><div class="line"> <span class="keyword">get</span> { <span class="keyword">return</span> msg; } </div><div class="line"> <span class="keyword">set</span> { msg = <span class="keyword">value</span>; }</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title">HasEvent</span></div><div class="line">{</div><div class="line"><span class="comment">// Declare an event of delegate type EventHandler of </span></div><div class="line"><span class="comment">// MyEventArgs.</span></div><div class="line"></div><div class="line"> <span class="keyword">public</span> <span class="keyword">event</span> EventHandler<MyEventArgs> SampleEvent;</div><div class="line"></div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">DemoEvent</span>(<span class="params"><span class="keyword">string</span> val</span>)</span></div><div class="line"> {</div><div class="line"> <span class="comment">// Copy to a temporary variable to be thread-safe.</span></div><div class="line"> EventHandler<MyEventArgs> temp = SampleEvent;</div><div class="line"> <span class="keyword">if</span> (temp != <span class="literal">null</span>)</div><div class="line"> temp(<span class="keyword">this</span>, <span class="keyword">new</span> MyEventArgs(val));</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title">Sample</span></div><div class="line">{</div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">Main</span>(<span class="params"></span>)</span></div><div class="line"> {</div><div class="line"> <span class="comment">//declare event</span></div><div class="line"> HasEvent he = <span class="keyword">new</span> HasEvent();</div><div class="line"> <span class="comment">//regist event</span></div><div class="line"> he.SampleEvent += </div><div class="line"> <span class="keyword">new</span> EventHandler<MyEventArgs>(SampleEventHandler);</div><div class="line"> <span class="comment">//value change trriger event</span></div><div class="line"> he.DemoEvent(<span class="string">"Hey there, Bruce!"</span>);</div><div class="line"> he.DemoEvent(<span class="string">"How are you today?"</span>);</div><div class="line"> he.DemoEvent(<span class="string">"I'm pretty good."</span>);</div><div class="line"> he.DemoEvent(<span class="string">"Thanks for asking!"</span>);</div><div class="line"> }</div><div class="line"> <span class="comment">//this function is registed </span></div><div class="line"> <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">SampleEventHandler</span>(<span class="params"><span class="keyword">object</span> src, MyEventArgs mea</span>)</span></div><div class="line"> {</div><div class="line"> Console.WriteLine(mea.Message);</div><div class="line"> }</div><div class="line">}</div></pre></td></tr></table></figure></t></t></p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/10/16/Informal essay/blog1/" itemprop="url">
This is my first blog
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-10-16T14:24:00+08:00" content="2016-10-16">
2016-10-16
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/Informal-essay/" itemprop="url" rel="index">
<span itemprop="name">Informal essay</span>
</a>
</span>
</span>
<span class="post-comments-count">
|
<a href="/2016/10/16/Informal essay/blog1/#comments" itemprop="discussionUrl">
<span class="post-comments-count ds-thread-count" data-thread-key="2016/10/16/Informal essay/blog1/" itemprop="commentsCount"></span>
</a>
</span>
<span id="/2016/10/16/Informal essay/blog1/" class="leancloud_visitors" data-flag-title="This is my first blog">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>yeah,i want to say something,but now,i must to eat my lunch,so hungry~</p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</section>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<section class="site-overview sidebar-panel sidebar-panel-active ">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image"
src="/images/icon.png"
alt="easy" />
<p class="site-author-name" itemprop="name">easy</p>
<p class="site-description motion-element" itemprop="description">So, i can say "That's easy."</p>
</div>
<nav class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives">
<span class="site-state-item-count">5</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<a href="/categories">
<span class="site-state-item-count">4</span>
<span class="site-state-item-name">分类</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags">
<span class="site-state-item-count">12</span>
<span class="site-state-item-name">标签</span>
</a>
</div>
</nav>
<div class="links-of-author motion-element">
<span class="links-of-author-item">
<a href="https://github.com/ea5y" target="_blank" title="GitHub">
<i class="fa fa-fw fa-github"></i>
GitHub