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

Is c# pass by value?

565


What is lazy in c#?

590


What is string interpolation in c#?

623


What is using keyword?

609


Why are strings immutable c#?

550






What is the use of protected in c#?

601


What is difference between float and decimal?

608


Int map to which .net types?

646


How can it prevents DLL Hell assembly versioning in .NET?

625


What's the difference between WindowsDefaultLocation and WindowsDefaultBounds?

713


What is as keyword in c#?

666


Can a struct be null?

580


How many bytes is an int in c#?

590


Is static thread safe?

579


What is the default value of date?

541