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