When static constructor is invoked?

Answer Posted / shadab alam

static costructor of a class invoked automatically when
class is loded provided Main method is given.There is no
need to create instance of a class.

we can prove it by following program in c#

using System;
class aa
{
static aa()
{
Console.Write("without instance");
}
public static void Main()
{

}

}


output will be
---------------
without instance

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of thread join in c#?

495


What is a value type in c#?

498


Can property be private in c#?

492


What are jump statements in c#?

499


Can we inherit a private class in c#?

458






Is datetime immutable c#?

495


What do you mean by saying a "struct is a value type"?

516


Why do we need singleton pattern in c#?

483


What is the difference between int16 and int32 in c#?

472


what optimizations does the c# compiler perform when you use the /optimize+ compiler option?

590


How more than one version of an assembly can keep in same place?

514


What is the default value of datetime in c#?

488


What is the difference between package and interface?

489


Is linkedhashset synchronized?

562


What is the use of dll file in c#?

461