If it were me, I'd create a class derived from
List
, and write accessor functions that used LINQ to find what you want.
public class MyList : List<MyWord>
{
public MyWord ByCapitol(string capitol)
{
var country = (from item in this
where item.Capitol == capitol
select item).First();
return (MyWord)country;
}
}
And so on. BTW, your object initialization can go a lot smoother if you do something like this:
MyList myList = new MyList();
myList.Add(new MyWord(){CountryName="USA",
Capitol="Washington, DC",
Area="Some area info"});
You should also change your constructor and add another:
public class MyWord
{
public MyWord() {};
public MyWord(string name, string capitol, string area)
{
this.CountryName = name;
this.Capitol = capitol;
this.Area = area;
}
}
That makes your oject much more versatile with regards to initialization.