Blog

Select a specific record in lambda C#

Lambda

Select a specific record in lambda C#

  1. Create a console application and create a list of customers in it.
				
					         var customerList = new List<Customer>()
            {
                new Customer{CustomerCode=101,CustomerName = "Steve"},
                new Customer{CustomerCode=102,CustomerName = "Mark"},
                new Customer{CustomerCode=103,CustomerName = "Bill"},
                new Customer{CustomerCode=104,CustomerName = "Dell"}

            };
				
			

2. Now with the help of lambda expression, select a specific record from the customer list where customer code = 102

				
					var result = customerList.Find(a => a.CustomerCode == 102);
				
			

3. Now we will print the result in the console

				
					Console.WriteLine(result.CustomerCode);
Console.ReadLine();
				
			

The result will be as follows

dotnetcoaching

Please commecnt about how we can modify the post for better and please share the post so the dotnercoaching can be more accessable and you become a part of our mission to spread free knowledge to make a better future.

Subhajit
maxcoach-shape-01
maxcoach-shape-02

Free 10 Days

Master Course Invest On Self Now

Subscribe & Get Your Bonus!
Your infomation will never be shared with any third party