| Author: Selva 28 Sep 2008 | Member Level: Silver | Rating:   Points: 3 |
Hi, Static constructors are used for initializing the static data members. Also it is useful when the action needs only once.
Static constructor is invoked before the first instance of the class is created. Otherwise any static member is referred.
class A { static A() { //Static constructor // } }
|
| Author: sairam kolasani 29 Sep 2008 | Member Level: Gold | Rating:  Points: 2 |
Static Constructor invokes when ur creating first instance of the class.
These are used to initialise static members of the class.
|
| Author: Vivek 29 Sep 2008 | Member Level: Gold | Rating:    Points: 6 |
There are two types of constructors: instance constructors and static constructors. Instance constructors are constructors that initialize objects. Static constructors are constructors that initialize classes.
Initializing Classes at Load Time C# ensures that a class is always initialized before it is used in code in any way. This guarantee is achieved by using static constructors. You can declare a static constructor like an instance constructor but prefix it with the keyword static, as follows: class Example { static Example( ) { ... } }
The static constructor for a class is executed before any instances of the class are created. The static constructor for a class is executed before any static member of the class is referenced. The static constructor for a class is executed before the static constructor of any of its derived classes is executed. The static constructor for a class never executes more than once.
|
| Author: Miss Meetu Choudhary 13 Feb 2009 | Member Level: Diamond | Rating:  Points: 5 |
A procedure or function or method that is used for creating and initializing objects. In any language, constructor is called after the object has been created and is used mainly to initialize the object's internal state i.e. there member variables. It is a special method that initializes an object when the object is created. In the class, a constructor has the same name as the class.
we have following types of constructors
1. copy constructor 2. default constructor 3. naval constructor 4. universal constructor 5. virtual constructor 6. constructor function 7. constructor brabham 8. taller del constructor
e.g. of copy constructor
class a { public int x; public a() { x=10; } public a(class z) \\ copy constructor { x=100; } } class b { public static void Main() { a obj1 = new a(); System.Console.WriteLine(x) ; b obj2 = new a(obj1); System.Console.WriteLine(x) ;
} } output 10 100;
Thanks and Regards Miss Meetu Choudhary (Site Coordinator) Go Green Save Green My Profile on Google
|