to ljj77:
有没有例子?
有没有例子?
解决方案 »
- C# 如何将dataGridView1里的数据批量插入、更新到SQL数据库
- 求助!!!
- 能不能帮我看下这段代码有错吗?为什么那个sendmessage语句中的msg指令老是报错。。
- 看到这样的情况,我很无奈
- (Help)C#/C++/VB生成的DLL是否可以在不同语言环境下调用(在线等)
- 在C#中Debug运行情况和直接运行Debug版本编译的exe程序运行情况不一样
- 如何在子窗体中再包含子窗体?
- 如何保护软件包里的exe不会被独立运行?
- 【socket】通讯成功、却无法传输文件,在线等
- (续)能否通过一个窗口句柄在c#中控制一个外部的窗口?(mycreatedream)
- 在线等待!急急急........
- 在主程序接收多个客户端发过来的大批量数据并同时放到一个数组中会占用很多CPU请大家帮助解决一下。
{
public delegate void MyHandler(int i); public static void Test(int i)
{
Console.WriteLine("static:{0}",i);
} public void Test2(int i)
{
Console.WriteLine("instance:" + i);
} public static void Process(MyHandler mh)
{
mh(12);
} public static void Main()
{ TestDel td = new TestDel(); MyHandler mh = new MyHandler(TestDel.Test);
mh += new MyHandler(td.Test2); Process(mh);
}
}
===
直接调用啊
{
public void Whatever(int i)
{
Console.WriteLine("AnotherClass : instance:" + i);
}
}class TestDel
{
public delegate void MyHandler(int i); public static void Test(int i)
{
Console.WriteLine("static:{0}",i);
} public void Test2(int i)
{
Console.WriteLine("instance:" + i);
} public static void Process(MyHandler mh)
{
mh(12);
} public static void Main()
{ TestDel td = new TestDel(); MyHandler mh = new MyHandler(TestDel.Test);
mh += new MyHandler(td.Test2); AnotherClass ac = new AnotherClass();
mh += new MyHandler(ac.Whatever); Process(mh);
}
}output:
static:12
instance:12
AnotherClass : instance:12
{
public void Whatever(int i)
{
Console.WriteLine("AnotherClass : instance:" + i);
}
}class TestDel
{
public delegate void MyHandler(int i); public static void Test(int i)
{
Console.WriteLine("static:{0}",i);
} public void Test2(int i)
{
Console.WriteLine("instance:" + i);
} public static void Process(MyHandler mh)
{
mh(12);
} public static void Main()
{ TestDel td = new TestDel(); MyHandler mh = new MyHandler(TestDel.Test);
mh += new MyHandler(td.Test2); AnotherClass ac = new AnotherClass();
mh += new MyHandler(ac.Whatever); Process(mh);
}
}output:
static:12
instance:12
AnotherClass : instance:12
{
//字符串排序
public void StringSort()
{
Console.WriteLine("排序字符串.");
} //数组排序
static public void ArrayMethod()
{
Console.WriteLine("排序数组.");
}
}public class MainClass
{
static public void Main()
{
MyClass p = new MyClass(); MyDelegate d = new SortDelegate(StringSort);
//调用委托
d(); d = new SortDelegate(ArrayMethod);
//调用委托,
d();
}
}