How to create a constructor in a class in C#? - Biz Tech

How to create a constructor in a class in C#?

Listen
 public class MyClass
{
    public MyClass(string name, int age)
    {
        this.Name = name;
        this.Age = age;
    }

    public string Name { get; set; }
    public int Age { get; set; }
}

MyClass myObject = new MyClass("John", 30);
Console.WriteLine(myObject.Name);
Console.WriteLine(myObject.Age);