class Myclass
{
public string name { get; set; }
public decimal age { get; set; }
}
class Program
{
static void Main(string[] args)
{
List<string> l = new List<string>();
l.Add("di"); l.Add("marks");
var list = new List<Myclass> { new Myclass { name = "di",age = 0 }, new Myclass { name = "marks", age = 0 }, new Myclass { name = "grade", age = 0 } };
list.Where(w => l.Contains(w.name)).ToList().ForEach(i => i.age = 10);
list.ForEach(i => Console.WriteLine(i.name + ":" + i.age));
Console.ReadKey();
}
}
23 August 2017
Fancy LINQ operation
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment