Thursday 12 July 2018

Select ,Any and All operator in Linq C#





using ConsoleApplication3.Model;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace ConsoleApplication3

{

    class Program

    {

        static void Main(string[] args)

        {





            List<Employee> li = new List<Employee>()

        {

            new Employee{id=1,name="Ali",salary=50000},

           new Employee{id=2,name="Ahmed",salary=30000},

          new Employee{id=3,name="Ahsan",salary=50000},

          new Employee{id=4,name="Asim",salary=40000},

          new Employee{id=5,name="Asad",salary=10000},





        };



        //  var  list = li.Select(x => new { ID = x.id, Name = x.name });

            //var list = li.ToList();







            //foreach (var item in list)

            //{

            //    Console.WriteLine("ID: " + item.id + "\nName" + item.name);

            //}



            //bool a = li.All(x => x.salary >= 10000);

            bool b = li.Any(x => x.salary > 30000);



            Console.WriteLine(b);







       

        }

    }

}

-----------------------------------------------------------------------------------------------
 class Employee
    {
        public int id { get; set; }
        public string name { get; set; }
        public int salary { get; set; }


    }

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...