// Created by vince
// Copyright (c) 2014年 vince. All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace delegate_test
{
//delegate type
delegate void myDelegate(string name);
class Program
{
static void Main(string[] args)
{
invokeDelegate(man, "vince");
invokeDelegate(lady, "Apple");
}
//using delegate to call method
static void invokeDelegate(myDelegate hello, string name)
{
hello(name);
}
//method
static void man(string name)
{
Console.WriteLine("Hi, Mr."+name);
}
static void lady(string name)
{
Console.WriteLine("Hey, Ms."+name);
}
}
}
Google Code Prettify
2014年11月7日 星期五
C# delegate(委派) 使用教學
訂閱:
張貼留言 (Atom)

sex hikaye
回覆刪除