Write Hello World Program Using Constructor Method

Introduction:

The basic purpose of this article is to help the beginner level programming student who has no experience in programming.

Background:

This article belongs to basic C# program language, because each student has a different reason to write a program, but I am writing this program with some different strategies to enhance the thinking of new developers in the field of programming.

Using Code:

Step 1:
Create a new project of C#, which is normally Console Application based.

console

Step 2: After creating the project add Class in project,

project

Click on add button and the class is added in your project

Step 3: Make a default constructor In Class1.cs which is normally the same as class.

class

Step 4: Now make an instance of class in the main program (Program.cs),

program

Step 5: Run the program to press the start button when you want to see the result.

program

Step 6: Hello World appears in your front screen:

screen

Points of Interest/Remember:

What is default Constructor?

A default constructor is basically a type of method which calls itself when the program loads, because the default constructor always calls itself when the instance of class has been created. So when I create the instance of class, the default constructor called itself, which is in Class1.cs,

  • The class & constructor name is always the same.
  • You should try writing this on your own.