When I'm finding an item from List and trying to change one of its properties, it just stays unchanged.
// My struct
struct Person
{
public string name;
public string surname;
}
// Fill up initial data
persons = new List<Person>();
person = new Person();
person.name = "Name";
person.surname = "Test";
persons.Add(person);
// Here person is found, I can see it by printing person.name and person.surname
Person foundPerson = persons.Find(p => p.surname == "Test");
// Let's change it
foundPerson.name = "Another name";
// But when I print all list's items, the name is still "Name". So previous string hasn't changed the original object.
persons.ForEach(delegate (Person person)
{
Console.WriteLine("Name: {0}", person.name);
});
What am I missing? What should I do in order to change the original value, which is contained in my list?