各位高手:
我想法是这样子滴:
代码:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
run(1);
}
static void run(int i)
{
Del d = new Del();
d.eve += new Del.DelEvent(d_eve);
Console.Read();
}
static void d_eve(int i)
{
Console.WriteLine("a");
}
}
class Del
{
delegate void DelEvent(int i);
public event DelEvent eve; }
}我想做的是,如何做才能使一运行run(int i)这方法,这个事件就马上执行,这要怎么实现呢。
因为这个事件与Del类中的属性变量等值没有关连,所以不能在属性值改变时引发这事件(我只知道这样引发事件)
还有其它方法吗
我想法是这样子滴:
代码:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
run(1);
}
static void run(int i)
{
Del d = new Del();
d.eve += new Del.DelEvent(d_eve);
Console.Read();
}
static void d_eve(int i)
{
Console.WriteLine("a");
}
}
class Del
{
delegate void DelEvent(int i);
public event DelEvent eve; }
}我想做的是,如何做才能使一运行run(int i)这方法,这个事件就马上执行,这要怎么实现呢。
因为这个事件与Del类中的属性变量等值没有关连,所以不能在属性值改变时引发这事件(我只知道这样引发事件)
还有其它方法吗
解决方案 »
- 如何实现中英文网站 asp.net
- asp.net树形问题,高手进
- 在线等!!!与数据库连接问题(很急)
- 伪静态之后
- 请问如何将double的数值转变为时间格式?
- 怎么用 IIS 配置 aspx 时 它总是出现要访问“C:\Documents and Settings\Administrator\My Documents\Web”
- 请教:如何保存一个类的实例到Application变量?
- asp.net mvc dropdownlist autopostback 刷新联动问题
- 我做了一个防止刷新的统计访客人数的程序。。。有点问题。。请高手帮忙看看错在那里。。谢谢`~~~
- 请教可以用代码中的自定dataset形成crystal report么?
- FormsAuthentication.RedirectFromLoginPage报错
- orcale数据访问
{
Del d = new Del();
d.eve += new Del.DelEvent(d_eve);
d.eve(i);
Console.Read();
}
{
static void Main(string[] args)
{
run(1);
}
static void run(int i)
{
Del d = new Del();
d.eve += new Del.DelEvent(d_eve);
d.Do(i);
Console.Read();
}
static void d_eve(int i)
{
Console.WriteLine(i);
Console.ReadLine();
}
}
class Del
{
public delegate void DelEvent(int i);
public event DelEvent eve;
public void Do(int i)
{
if (eve != null)
eve(i);
} }
这样加上去出错吧。。
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
run(1);
}
static void run(int i)
{
Del d = new Del();
d.eve += new DelEvent(d_eve);
d.mymethod(i);
Console.Read();
}
static void d_eve(int i)
{
Console.WriteLine(i);
Console.WriteLine("a");
}
}
delegate void DelEvent(int i);
class Del
{
public event DelEvent eve; public void mymethod(int i)
{
eve(i);
} }
}