Getting an item in a list

c#, list

Solution

Using the `List<T>.Find` method in C# 3.0:

var config = Configurations.Find(item => item.Name == "myConfig");

In C# 2.0 / .NET 2.0 you can use something like the following (syntax could be slightly off as I haven't written delegates in this way in quite a long time...):

Configuration config = Configurations.Find(
    delegate(Configuration item) { return item.Name == "myConfig"; });

Problem

I have the following list item ``` public List<Configuration> Configurations { get; set; } public class Configuration { public string Name { get; set; } public string Value { get; set; } } ``` How can I pull an item in configuration where name = value? For example: lets say I have 100 configuration objects in that list. How can I get : Configurations.name["myConfig"] Something like that? UPDATE: Solution for .net v2 please

Original source