A struct, when copied, will carry into the new copy new value types such an int and DateTime and clearly changing these at one copy does not alter them at the other copy... but what about reference types for pointers? If it's a string, there will be a new string at the copy with a new pointer and changing one string does not affect the other, but if it's a class, the two structs will both have pointers to the same spot on the heap for the class. If you use structs instead of classes as your secondary actors then you cannot change up the getsetters on them after the fact, you to new up a new secondary struct to make a change to a copy of a class clinging to it at a property. The same trick obviously can be done to get around dupe pointer problems with classes.
No comments:
Post a Comment