You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
878 B
C#

using System;
using System.Collections.Generic;
using System.Text;
6 years ago
//命名空间同级调用方只需要引用定义类库就能使用不需要使用Uing语句引入定义委托的命名空间。
public delegate string NamespaceLevelDelegate();
public delegate string ToLowerDelegate(string source);
namespace Study.DelegateSeries.Core
{
6 years ago
//类同级:最常用和推荐的,可见范围与使用方法与类相同。
public delegate string ClassLevelDelegate();
6 years ago
public class DeclareDelegateDemo
{
//类内部方法同级:可见范围与使用方法与类中方法相似,调用方须先调用类,后再调用委托。
public delegate string MethodLevelDelegate();
6 years ago
public string GetClassName()
{
//方法体内:不允许定义委托
6 years ago
return "DeclareDelegateDemo";
}
}
}