I have a class named Book with a property of String :
private string? _bookName;
public string? BookName
{
get
{
return _bookName;
}
set
{
_bookName = value;
}
}
and I created an instance of it in main and I can loop the items , but my problem is I don't want to user be able to add INT for this property , how can I prevent that?
List<Book> books = new();
Book firstBook = new()
{
BookName = Console.ReadLine(),
};
books.Add(firstBook);
foreach (Book bookList in books)
{
Console.WriteLine
(
$"The Name Of The Book Is : {bookList.BookName} , "
)
}
now the user can insert number as book name , how do I fix that? thanks