Setting each property after construction is tedious and easy to half-finish. A constructor takes what the object needs to exist.
Program.cs
using System;
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public Book(string title, string author)
{
Title = title;
Author = author;
}
public string Describe()
{
return $"Book: {Title} by {Author}";
}
}
class Program
{
static void Main()
{
Book b = new Book("1984", "Orwell");
Console.WriteLine(b.Describe());
}
}
Output
Book: 1984 by Orwell
The constructor has the class's name and no return type. Describe is a method on the object — note it uses Title directly, because it is inside the class that owns it.
Why this is better
A Book cannot now exist without a title and an author. The type itself rules out a half-built object, rather than you remembering to finish one.