using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsoleApp
{
public class LINQTest
{
public class Employee
{
public int Id { get; set; }
public string name { get; set; }
}
public static void Main()
{
List<Employee> list = new List<Employee>();
list.Add(new Employee() { Id = 1, name = "a" });
list.Add(new Employee() { Id = 2, name = "b" });
list.Add(new Employee() { Id = 3, name = "c" });
list.Add(new Employee() { Id = 4, name = "d" });
//update all properties to same value in a generic list
list = list.Select(c => { c.name = "K"; return c; }).ToList();
foreach (var item in list)
{
Console.WriteLine(string.Format("Id = {0}, Name = {1}", item.Id, item.name));
}
}
}
}This code snippet is for Update All Properties to Same Value in a Generic List.