EDIT
Based on your comment, it seems like you want a Dictionary (as already suggested) where your object holds all your 'values.'
For Instance:
public class MyClass
{
public int AreaCount;
public string foo;
public bool bar;
}
//Create dictionary to hold, and a loop to make, objects:
Dictionary<string, MyClass> myDict = new Dictionary<string, MyClass>();
while(condition)
{
string name = getName(); //To generate the string keys you want
MyClass mC = new MyClass();
myDict.Add(name, mC);
}
//pull out yours and modify AreaCount
myDict["Area1"].Value.AreaCount = 50;
Alternatively, you could add a string
"Name" to you class (I'm using fields for the example, you'd probably use properties) and use Linq:
//Now we have a list just of your class (assume we've already got it)
myClass instanceToChange = (from items in myList
where Name == "Area1"
select item).FirstOrDefault();
myClass.AreaCount = 50;
Does that help more?
ORIGINAL RESPONSE
I'm not completely sure what you're asking, but I'll give it ago.
Given a list of Objects from which you need to grab a particular object, there are (generally) 4 ways- depending on your specific needs.
The Generic List<T>
really only does this well at all if your object already supports some kind of searching (like String.Contains()).
A SortedList uses IComparer to compare and sort the Key values and arrange the list that way.
A Dictionary stores a Key and Value so that KeyValuePair
objects can be retrieved.
A HashTable uses Keys and Values where the Keys must implement GetHashCode()
and ObjectEquals
The specific one you need will vary based on your specific requirements.