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的更多相关文章

  1. Swift开发教程--关于Existing instance variable '_delegate'...的解决的方法

    xcode编译提示问题:Existing instance variable '_delegate' for property 'delegate' with  assign attribute mu ...

  2. C#_delegate - 异步调用实例 BeginInvoke EndInvoke event

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. C#_delegate - 有返回值手工调用

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  4. C#_delegate - 用委托实现事件,Display和Log类都使用Clock对象

    //public event SecondChangeHandler OnSecondChange; 若将委托加上event,则视作是事件,不是委托,外围就不能直接对OnSecondChange传值 ...

  5. C#_delegate - Pair<T> 静态绑定

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. C#_delegate - Pair<T> & 简单顺序逆序 & 方法委托(在Pair类下)&枚举类型 混搭使用

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. C#_delegate和事件 - 如果金额小于0则触发事件

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. C#_delegate EndInvoke

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. C#_delegate - 调用列表 计算阶乘

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Dele ...

  10. C#_delegate - 值参数和引用参数

    值参数不能加,引用参数可以. 引用参数是共享的 using System; using System.Collections.Generic; using System.Linq; using Sys ...

随机推荐

  1. 【转】如何把ndk编译出来的可执行文件伪装成so打包到apk中

    原文网址:http://jeyechao.iteye.com/blog/2164286 ndk编译出来的共享库,eclipse会自动打包到apk中,而编译出来的可执行文件则不会. 要想可执行文件自动被 ...

  2. 【转】编译Android系统源码和内核源码

    原文网址:http://blog.csdn.net/jiangwei0910410003/article/details/37988637 好长时间没有写blog了,之所以没有写,主要还是工作上的事, ...

  3. jQuery遍历DOM

    jQuery提供了多种遍历DOM的方法.遍历方法中最大的种类是树遍历. 向上遍历DOM树 parent():返回被选元素的直接父元素 parents():返回被选元素的所有祖先元素,它一直遍历到根元素 ...

  4. java jvm学习笔记七(jar包的代码认证和签名)

    欢迎装载请说明出处:http://blog.csdn.net/yfqnihao 前言: 如果你循序渐进的看到这里,那么说明你的毅力提高了,jvm的很多东西都是比较抽像的,如果不找相对应的代码来辅助理解 ...

  5. HDU 5606 tree 并查集

    tree 把每条边权是1的边断开,发现每个点离他最近的点个数就是他所在的连通块大小. 开一个并查集,每次读到边权是0的边就合并.最后Ans​i​​=size[findset(i)],size表示每个并 ...

  6. convert nocdb to cdb using dbms_pdb

    convert nocdb to cdb using dbms_pdb 本文介绍将nocdb转换为cdb   环境介绍: ORACLE_HOME: /u01/app/oracle/product/12 ...

  7. Python脚本控制的WebDriver 常用操作 <二十三> wait

    测试用例场景 Wait类的使用场景是在页面上进行某些操作,然后页面上就会出现或隐藏一些元素,此时使用Wait类的until方法来等待这些效果完成以便进行后续的操作.另外页面加载时有可能会执行一些aja ...

  8. Android的有关EditText的能多行显示但无法禁止自动换行的Bug!

    需求: 使 EditText或TextView 支持 多行显示,但是不自动换行,即能水平滚动较长的内容. Bug: 想当然的,在XML定义中设置如下,应该就可以了. android:scrollHor ...

  9. Fidder的几点补充

    坦克兄写的Fiddler教程很好很详细 链接这里:http://www.cnblogs.com/TankXiao/archive/2012/02/06/2337728.html 补充一: Fiddle ...

  10. codeforce 600C - Make Palindrome

    练习string 最小变换次数下,且字典序最小输出回文串. #include <cstdio> #include <cstring> #include <cmath> ...