Ebeworld’s Weblog

Trying to create

C# and Java static constructors

Where should be initialize the static field? If we do it non static initializer, each time when object created the static field will be initialized and that not efficient and may undo what we have done in up to that moment. The solution is to use static constructor. in Java, it is used when class is loaded and written as[it is called static block] 

static{

//..something

}

but in C#, it is accomplished by real static constructor

static MyClass{

//.. do something

}


November 22, 2008 - Posted by ebeworld | Interview Questions | | No Comments Yet

No comments yet.

Leave a comment