Initial add of three projects
This commit is contained in:
47
BooksLambda/Program.cs
Normal file
47
BooksLambda/Program.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BooksLambda
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var books = new BookRepository().GetBooks();
|
||||
//var cheapBooks = books.FindAll(IsCheaperThan10Dollars);
|
||||
var cheapBooks = books.FindAll(b => b.Price<10);
|
||||
|
||||
foreach (var book in cheapBooks)
|
||||
{
|
||||
Console.WriteLine(book.Title);
|
||||
}
|
||||
}
|
||||
|
||||
//static bool IsCheaperThan10Dollars(Book book)
|
||||
//{
|
||||
// return book.Price < 10;
|
||||
//}
|
||||
}
|
||||
|
||||
public class BookRepository
|
||||
{
|
||||
public List<Book> GetBooks()
|
||||
{
|
||||
return new List<Book>
|
||||
{
|
||||
new Book(){Title="Title 1", Price=5.25m},
|
||||
new Book(){Title="Title 2", Price=9.25m},
|
||||
new Book(){Title="Title 3", Price=10.75m}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class Book
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user