110,536
社区成员
发帖
与我相关
我的任务
分享
class Program
{
static Program()
{
Console.WriteLine("Constructor");
}
static void Program_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
}
static void Main(string[] args)
{
AppDomain d = AppDomain.CreateDomain("Test");
UnhandledExceptionEventHandler h = Program_UnhandledException;
typeof(AppDomain).GetEvent("UnhandledException").AddEventHandler(d, h);
}
}
class Program
{
static Program()
{
Console.WriteLine("Constructor");
}
static void Program_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
}
static void Main(string[] args)
{
AppDomain d = AppDomain.CreateDomain("Test");
UnhandledExceptionEventHandler h = Program_UnhandledException;
d.SetData("Test", h);
}
}
class M
{
M()
{
Console.WriteLine("Instance");
}
static M()
{
Console.WriteLine("Static");
}
public static void F()
{
Console.WriteLine("M.F");
}
}
class Program1
{
static void Main(string[] args)
{
Action a = M.F;
RuntimeHelpers.PrepareDelegate(a);
}
}
class Program2
{
static void Main(string[] args)
{
Action a = M.F;
RuntimeHelpers.RunClassConstructor(a.Method.ReflectedType.TypeHandle);
}
}