Case 1 - I have a list of string, say
List<string> source = new List<string>();`
source.Add("one");
source.Add("two");
source.Add("three");
If i update the value for "two" using below code, it wont update the value.
Example -
source.ForEach(x => {if (x == "two"){x = "twenty";}});
Case 2 -
But when I have a List<ComplexObject> obj = new List<ComplexObject>()
with two property Key, DisplayText
with value as
1,"One"
2, "two"
And I try to update using below code, the value will be updated
obj.ForEach(x => {if (x.Key == 2){ x.DisplayText = "Update value for 2";}});
Though both are list but why is the behaviour different?