Пример #1
0
        static void Main(string[] args)
        {
            // args => express  // LambdaExpress
            // number => number*number;
            Func <int, int> square = number => number * number; //  first int is the argument data type, the second int is the return value datatype

            Console.WriteLine(square(5));

            // () => ... || x => .... || (x, y, z) => ...

            const int factor = 5;

            Func <int, int> multipler = n => n * factor;
            var             result    = multipler(10);

            Console.WriteLine(result);

            // Not LanbdaExpression

            List <Book> books      = new BookRespository().GetBooks();
            List <Book> cheapBooks = books.FindAll(IsCheaperThan10Dollars);

            foreach (var book in cheapBooks)
            {
                Console.WriteLine(book.Title);
                Console.WriteLine(book.Price);
            }



            // with LanbdaExpression
            List <Book> books0      = new BookRespository().GetBooks();
            List <Book> cheapBooks0 = books0.FindAll(book => book.Price < 10);
        }
Пример #2
0
 public BookController()
 {
     _bookRespository = new BookRespository();
 }