我有一个简单的方法:
private IList<Objective> createObjectives()
{
var objectiveNames = new[]
{
"Objective 1",
"Objective 2",
"Objective 3",
"Objective 4",
"Objective 5",
"Objective 6",
"Objective 7",
"Objective 8"
};
var objectives = from objectiveName in objectiveNames
select new Objective
{
Name = objectiveName,
Description = objectiveName + " Description",
ModifiedDate = DateTime.Now
};
return objectives.ToList();
}
这是我可以转换为使用 lambdas 的东西吗?这样做有什么好处吗?