The volatile keyword ensures that read/writes to a variable are done without being optimized to a register or temporary memory. While it's good practice to mark members as volatile that may be accessed by multiple threads; if the member is only ever accessed via the property set/get (as in the sample) and the set/get implementations have no need to cache the value of _foo (the sample code has no need to cache the value) then volatile won't have any affect.
↧