不知楼主是否清楚委托的含义?函数指针应该知道吧?不知楼主是不是这个意思?:using System; using System.Collections.Generic; using System.Text; namespace c1 { public delegate void cm(); class am { } class bm : am { public bm() { string a = Console.ReadLine(); Console.WriteLine(a); }
public void Print() { System.Console.WriteLine("hello"); }
} class Program { static void Main(string[] args) {
bm b = new bm(); //直接调用构造函数,不用另外编码调用! cm c=new cm(b.Print); c();
using System.Collections.Generic;
using System.Text;
namespace c1
{
public delegate void cm();
class am
{
}
class bm : am
{
public bm()
{
string a = Console.ReadLine();
Console.WriteLine(a);
}
public void Print()
{
System.Console.WriteLine("hello");
}
}
class Program
{
static void Main(string[] args)
{
bm b = new bm(); //直接调用构造函数,不用另外编码调用!
cm c=new cm(b.Print);
c();
Console.ReadLine();
}
}
}