Sudhir Goswami
What are destructors in C#?
By Sudhir Goswami in C# on Jun 06 2013
  • Dipankar Hazari
    Jun, 2013 11

    Constructor is a method (consists zero argument) in a class,basically constructor gets executed when its object is created.Basically we put the initialized code in the constructor. Example: public class myClass {public myClass(){// This is the constructor method.}// rest of the class members goes here.public myClass(int a){//Some code here}public myClass(int a,string str) {//some code here} }A class or struct may have multiple constructors that take different arguments. Constructors enable the programmer to set default values, limit instantiation, and write code that is flexible and easy to read. If you do not provide a constructor for your object, C# will create one by default that instantiates the object and sets member variables to the default values as listed in Default Values Table (C# Reference).

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS