如何将委托类型作为函数参数???

liuyang2003 2004-10-26 10:01:56
class Test
{
delegate void SimpleDelegate();
static void F()
{
System.Console.WriteLine("Test.F");
}
public void kk(int count, SimpleDelegate t)
{

for (int i = 0; i < count; i++)
t();
}
static void Main()
{
SimpleDelegate ff = new SimpleDelegate(F);
Test test2 = new Test();
test2.kk(3,ff);
}
}
运行会出错:
Inconsistent accessibility: parameter type 'ConsoleApplication1.Test.SimpleDelegate' is less accessible than method 'ConsoleApplication1.Test.kk(int, ConsoleApplication1.Test.SimpleDelegate)'

我想知道如何将委托类型作为函数参数???
...全文
162 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
luaiping 2004-10-26
  • 打赏
  • 举报
回复
public delegate void SimpleDelegate();
bruce007 2004-10-26
  • 打赏
  • 举报
回复
在 delegate void SimpleDelegate(); 加一个public 试试

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧