This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Sunday, March 5, 2023

constructor in c# example

 constructor in c# example


In this tutorial, we will learn about the C# constructors and their types with the help of examples.


In C#, a constructor is similar to a method that is invoked when an object of the class is created.



constructor in c# example:


using System;


namespace Constructor {


  class Car {   


    // parameterless constructor

    Car() {

      Console.WriteLine("Car Constructor");

    }

 

    static void Main(string[] args) {


      // call constructor

      new Car();

      Console.ReadLine();

     

    }

  }

}

No comments:

Post a Comment