Static Constructor
- Used to initialize the static members of a class.
- Can not access non-static members.
- Executes before the first instance of a class. We can not determine the time of execution.
- Executes by the CLR not by the object of a class.
- There are no parameterized static constructors since it is handled by the CLR not by the object.
- Time of execution might be at the loading of contained assembly.
Private Constructor
- Used to restrict a class to be instantiated and to be inherited.
- Used whenever a class contains only static members.
No comments:
Post a Comment