搜索一个数组然后从另一个数组中获取相应的数据

Searching one array then get the corresponding data from another array

如何从用户输入中搜索一个数组中的数据,并从其他数组中获取相应的数据?例如,用户希望通过在另一个数组中搜索具有 ID 号的姓名来获取信息。

对于这种情况,我使用 Linq。

 public class Person
 {
      public string Name { get; set; }
      public int Id { get; set; }
 }


 IEnumerable<string> names = data.Where(x => input.Any(y => y.Id == x.Id)).Select(x => x.Name);