how do I add a constructor method to a class that I created
I made a book class and I now need it to be a booktest that has a constructor that initializes the properties
using System;
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public DateTime Date { get; set; }
public Book(string title, string author, DateTime date)
Title = title;
Author = author;
Date = date;
}
public override string ToString()
return String.Format("Title : {0}\nAuthor : {1}\nPublished : {2}", Title, Author, Date.Year);
class Program
static void Main()
Book b = new Book("radars adventure", "Nick james", new DateTime(1989, 1, 1));
Console.WriteLine(b);
Console.ReadKey();