C# Constructors and Destructors

Constructors A constructor is a special class member that is executed when a new object is created. The constructor’s job is to initialize all of the public and private state of the new object and to perform any other tasks that the programmer requires before the object is used. In this article, we will create a new class to represent a triangular shape. This class will define three properties: the triangle’s height, base-length and area. To begin, create a new console application and add a class named “Triangle”. Copy and paste the following code into the class to create the … Click here to continue reading.