首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#中delegate施用

2012-10-09 
C#中delegate使用using Systemusing System.Collections.Genericusing System.Linqusing System.Textn

C#中delegate使用

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Demo{    public delegate int Fun(int i);    class Program    {         static void Main(string[] args)        {            Fun f = sqrt;            Console.WriteLine(f(5));            f = cube;            Console.WriteLine(f(5));            Console.ReadKey();        }        static int sqrt(int x)        {            return x * x;        }        static int cube(int x)        {            return x * x * x;        }    }}
?

热点排行