Alex Rivera | Logout

Getting an item in a list

Asked 2009-08-01T11:42:39.250
11

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

Edit
Report

1 Answer

0

Here's one way you could use:

static void Main(string[] args)
        {
            Configuration c = new Configuration();
            Configuration d = new Configuration();
            Configuration e = new Configuration();

            d.Name = "Test";
            e.Name = "Test 23";

            c.Configurations = new List<Configuration>();

            c.Configurations.Add(d);
            c.Configurations.Add(e);

            Configuration t = c.Configurations.Find(g => g.Name == "Test");
        }
answered 2009-08-01T11:52:11.367

Your Answer