2013年2月19日

C#的static constructor抛了异常会怎么处理?

摘要: stackoverflow上举了这个例子说明在C#中,如果static constructor只会被调用一次,即使抛了异常,也不会重试调用。如果抛了异常,那么在这个appdomain里面,这个类就不能用了。 示例代码: using System;public sealed class Bang{ static Bang() { Console.WriteLine... 阅读全文

posted @ 2013-02-19 10:30 fresky 阅读(251) 评论(0) 推荐(0) 编辑

C#的继承类中static constructor的调用问题

摘要: Eric Lippert写了一系列的关于static constructor的文章,1,2,3,4,可以读读对static constructor有更好的理解。 转一个其中的例子吧,假设有如下代码。 using System;class B{ static B() { Console.WriteLine("B cctor"); } public B() { Console.Write... 阅读全文

posted @ 2013-02-19 10:24 fresky 阅读(321) 评论(0) 推荐(0) 编辑

导航