I have a list of objects. These objects have three variables, ID, Name, & value. There can be a lot of objects in this list, and I need to find one based on the ID or Name, and change the value.
Example
class objec
{
public string Name;
public int UID;
public string value;
}
List<objec> TextPool = new List<objec>();
How would I find the one entry in TextPool that had the Name of ‘test’ and change its value to ‘Value’.
The real program has many more search options, and values that need changing, so I couldn’t just use a Dictionary (though Name and UID or unique identifiers).
Any help would be great
You could use LINQ to find it, then change the element directly:
If you wanted to change all elements that match, you could, potentially, even do:
However, I personally would rather split it up, as I feel the second option is less maintainable (doing operations which cause side effects directly on the query result “smells” to me)…