Esempio:
public class Person
{
private int _id;
private string _name;
public int ID { get { return _id; } set { _id = value; } }
public int Name { get { return _name; } set { _name = value; } }
public Person(int id, string name)
{
_id = id;
_name = name;
}
}
{
private int _id;
private string _name;
public int ID { get { return _id; } set { _id = value; } }
public int Name { get { return _name; } set { _name = value; } }
public Person(int id, string name)
{
_id = id;
_name = name;
}
}
public void CreateAndSearchList()
{
List<Person> myList = new List<Person>();
myList.Add(new Person(1, "Aldo"));
myList.Add(new Person(2, "Giovanni"));
myList.Add(new Person(3, "Giacomo"));
Person myLocatedObject = myList.Find(delegate(Person p) {return p.ID == 1; });
}
{
List<Person> myList = new List<Person>();
myList.Add(new Person(1, "Aldo"));
myList.Add(new Person(2, "Giovanni"));
myList.Add(new Person(3, "Giacomo"));
Person myLocatedObject = myList.Find(delegate(Person p) {return p.ID == 1; });
}


0 commenti
Posta un commento