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

Explain About CLS?

550


What is the difference between static and private constructor?

480


How does the lifecycle of Windows services differ from Standard EXE?

526


Is inheritance possible in c sharp?

639


Why do we overload constructors?

502






What is executescalar in c#?

466


How do you pass reference parameters in c#?

460


Does c# support multiple class inheritance?

610


Explain the ways to deploy an assembly?

516


What is the difference between an application domain and a process?

486


How many variables do you need?

504


Explain About disco and uddi

708


Is array value type in c#?

596


What do you mean by delegates and explain different types of delegates?

516


What is difference between array and collection in c#?

449