I was thinking, and I'm not sure, but help me.
If you have a list item, and there is an object that you need to change its property, say a cluster property in myClass is "status" I am searching my list with a four-loop and I get my object, so I
myClass item = items [i];
If I want to change the "status" property, then I do this for example:
item.Status = "new status"; My question / point is: "item" is still linked to the item item, so if I execute the above line, then it will also change in the list without setting it. : items [i] = items;
Hope this is clear.
Thanks in advance.
code item.Status = "new status";
the list item will change
item [i]
indicates a MyClass object.
When you myClass items = items [i];
, then it is referenced by both items
and items [i]
.
So when you change one of these properties, then item.Status = "new status";
You are actually making changes in your myClass object which now has two names, items
and items [i]
.
You can also use the item [i]. Status = "new status";
. Both work the same.
set items [i] = items;
There is no effect, because both the references are already referenced.
Comments
Post a Comment