why would we ever need a static constructor. what does it mean by a static constructor ?
static refers to "not associated with specific object" and can be called using class reference rather than object reference. But how does this apply to a constructor
shukla raghav
Ranch Hand
Joined: Aug 03, 2008
Posts: 184
posted
0
sorry i got constructors are not static...
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
4
posted
0
Never heard of a "static constructor". A constructor has an access modifier (public/private/protected/---) the name of the class and (parameters). You never write static.
Embla Tingeling
Ranch Hand
Joined: Oct 22, 2009
Posts: 237
posted
0
shukla raghav wrote:why would we ever need a static constructor. what does it mean by a static constructor ?
static refers to "not associated with specific object" and can be called using class reference rather than object reference. But how does this apply to a constructor
The closest you come to a static constructor is a static initializer. It works like a static default constructor would work if it existed.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
4
posted
0
It never occurred to me that could mean initialisers. Well caught, uj.