My question is: Is there any way that I can access constructor property after creating a new object.
I have created this class:
class Book
{
private string Title { get; set; }
private string Author { get; set; }
private string ISBN { get; set; }
public bool Available { get; set; }
public Book(string title, string author, string isbn)
{
this.Title = title;
this.Author = author;
this.ISBN = isbn;
}
}
Then I create a new object in a following way:
Book myBook = new Book("Strategic Management", "John Doe", "1234567");
How can I extract title from the object above? I need to use the Title in the following syntax:
public void RemoveLoan(Book oldLoan)
{
var item = Loans.SingleOrDefault(x => x.Book.Title == oldLoan.Title);
if (item != null)
{
Loans.Remove(item);
}
}
Thanks in advance