Как мне проанализировать массив для конкретного значения и выполнить задачу
I've created my own class for a book and need to analyze the array for whether or not it contain true or false and then add 5 to anything that contains true. This is the class ``` class Book { public double Price { get; set; } public string BookName { get; set; } public bool Hardcover { get; set; } public Book(string bookname, bool hardcover, double price) { Price = price; BookName = bookname; Hardcover = hardcover; } public override string ToString() { if (Hardcover == true) { return BookName + Price + Hardcover; } else { return BookName + Price + Hardcover; } } ``` thx for the help
Что я уже пробовал:
Мое текущее решение-использовать linq, но оно все еще не сработало, я также попробовал string compare
``` public Form1() { InitializeComponent(); } List<Book> MyBooks = new List<Book>(); private void Form1_Load(object sender, EventArgs e) { MyBooks.Add(new Book("Book 1", false, 5.50)); MyBooks.Add(new Book("Book 2", false, 5.50)); MyBooks.Add(new Book("Book 3", false, 5.50)); MyBooks.Add(new Book("Book 4", false, 5.50)); MyBooks.Add(new Book("Book 5", true, 5.50)); } private void Grid_Click(object sender, EventArgs e) { Button c = (Button)sender; List<Book> MyBooks = new List<Book>(); IEnumerable<String> bookQuery = from book in MyBooks where book is true select book; foreach (String p in MyBooks) { textBox1.Text = textBox1.Text + p.ToString() + Environment.NewLine; } } ```