I am working with a generic List which I add Employee objects to.
I know how to add and remove from it, but how do I “read” object data from it and how do I access methods and properties for a specific object in the list.
Let’s say the Employee class contains the property below, how do I access it to modify the objects data?
public string FirstNameData
{
get { return v_firstName; }
set { v_firstName = value; }
}
Assuming:
You have many options here…
First, you can index it directly:
You can enumerate over it:
If you are using .Net 3.5 or greater, you can use Linq exetnsions:
It all depends on what you want to do…