我有这个List
包含Story
类的实例:搜索对象的列表<Object>
List<Story> Stories = new List<Story>();
public class Story
{
public string Id { get; set; }
public double Height { get; set; }
public double Elevation { get; set; }
}
列表中的每个实例是唯一的:
Stories = {Story1, Story2, ...}
现在,在另一种方法我想在List
来搜索特定Story
而整个对象分配到新创建的对象
Story st = Find a Story in the Stories that its Story.Id=="Story2"
我怎样才能做到这一点?
谢谢。第一个答案没有奏效。它正在工作。 – Vahid
@Vahid没问题,我知道了。 ) –
感谢您的完整的答案。 – Vahid