I have a List<MyClass> MyList
where
public class MyClass
{
public string name { get; set; }
public string value { get; set; }
}
Given a name, I'd like to get the corresponding value. I have it currently implemented as:
MyList[MyList.FindIndex(item => String.Compare(item.name, "foo", 0) == 0)].value
Is there a cleaner way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…