Difference
between Constructor and Destructor in C#
-
S.No Constructor Destructor 1 It is a special type of method which will be executed automatically while creating an objectIt will be executed automatically while destroying object2 Constructor name must be same as class name with out return typeThe name of destructor must be same as class name with a ~(tilde) prefix and with out return type and with out access specifiers3 Syntax:public class_name(){}Syntax:~class_name(){}4 These are overloadableThese are not overloadable5 These are used to initialize the variables to open files or database connection etcIt is used to de-allocate the memory
No comments:
Post a Comment