class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
宠物年龄加名字长度的最大值
1895

被折叠的 条评论
为什么被折叠?



