C#_delegate - example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace Delegate
{
public delegate void Task(); class Program
{ static void Main(string[] args)
{
Task[] task = { MethodA, MethodB, MethodC};
string resp;
do
{ Console.WriteLine("Task-A");
Console.WriteLine("Task-B");
Console.WriteLine("Task-C");
Console.WriteLine("X exit");
resp = Console.ReadLine();
if (resp.ToUpper() == "X")
{
break;
}
try
{
int choice = int.Parse(resp) - 1;
task[choice]();
}
catch {
Console.WriteLine("Invalid number");
}
} while (true); Console.ReadLine(); } public static void MethodA() {
Console.WriteLine("A doing");
}
public static void MethodB()
{
Console.WriteLine("B doing");
}
public static void MethodC()
{
Console.WriteLine("C doing");
}
}
}
C#_delegate - example的更多相关文章
- Swift开发教程--关于Existing instance variable '_delegate'...的解决的方法
xcode编译提示问题:Existing instance variable '_delegate' for property 'delegate' with assign attribute mu ...
- C#_delegate - 异步调用实例 BeginInvoke EndInvoke event
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- C#_delegate - 有返回值手工调用
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- C#_delegate - 用委托实现事件,Display和Log类都使用Clock对象
//public event SecondChangeHandler OnSecondChange; 若将委托加上event,则视作是事件,不是委托,外围就不能直接对OnSecondChange传值 ...
- C#_delegate - Pair<T> 静态绑定
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- C#_delegate - Pair<T> & 简单顺序逆序 & 方法委托(在Pair类下)&枚举类型 混搭使用
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- C#_delegate和事件 - 如果金额小于0则触发事件
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- C#_delegate EndInvoke
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- C#_delegate - 调用列表 计算阶乘
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Dele ...
- C#_delegate - 值参数和引用参数
值参数不能加,引用参数可以. 引用参数是共享的 using System; using System.Collections.Generic; using System.Linq; using Sys ...
随机推荐
- jwplayer 网页在线播放插件
1.到官网 https://www.jwplayer.com/ 注册,取得key并下载免费版本(免费版只支持mp4格式): 2.编辑如下网页即可在线播放: <!DOCTYPE html> ...
- hbase分页查询
为了广大技术爱好者学习netty,在这里帮新浪微博@nettying宣传下他出版的新书 <netty权威指南>@nettying兄在华为NIO实践多年,这本书是他的技术和经验的一个结晶.N ...
- 学习xcode 博客
csdn http://blog.csdn.net/tianyitianyi1/article/category/1160169/2
- POJ 3177 Redundant Paths 边双(重边)缩点
分析:边双缩点后,消环变树,然后答案就是所有叶子结点(即度为1的点)相连,为(sum+1)/2; 注:此题有坑,踩踩更健康,普通边双缩短默认没有无向图没有重边,但是这道题是有的 我们看,low数组是我 ...
- HDU 5607 graph 矩阵快速幂 + 快速幂
这道题得到了学长的助攻,其实就是一个马尔科夫链,算出一步转移矩阵进行矩阵快速幂就行了,无奈手残 这是我第一回写矩阵快速幂,写的各种毛病,等到调完了已经8点44了,交了一发,返回PE,(发现是少了换行) ...
- prefuse学习(二)显示一张图
1. 把数据以点连线的方式在画面中显示 2. 数据按照数据的性别属性使用不同的颜色 3. 鼠标左键可以把图在画面中拖动 4. 鼠标右键可以把图放大或者缩小 5. 鼠标单击某个数据上,该数据点 ...
- HW6.9
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HDU-4655 Cut Pieces 数学,贪心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4655 先不考虑相临的有影响,那么总数就是n*prod(ai),然后减去每个相邻的对总数的贡献Σ( Mi ...
- HDU-1402 A * B Problem Plus FFT(快速傅立叶变化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1402 一般的的大数乘法都是直接模拟乘法演算过程,复杂度O(n^2),对于这题来说会超时.乘法的过程基本 ...
- POJ2486 - Apple Tree(树形DP)
题目大意 给定一棵n个结点的树,每个结点上有一定数量的苹果,你可以从结点1开始走k步(从某个结点走到相邻的结点算一步),经过的结点上的苹果都可以吃掉,问你最多能够吃到多少苹果? 题解 蛋疼的问题就是可 ...