I am trying to create a nuclear reference class in C # and I want to preserve field context, but I Also return the value to the received method:
class atomic reference (private object_value; public atomic reference) {_value = new object ();} public atomic reference (object value) { Optimistic Set (Price);} Public Object Comparison and Set (Object Newwell {Return Interlock. Exchange (Ref _ value, New Vale)}} Public Zero OptimisticSet {object} while {_value == Interlocked.CompareExchange (reference_value, _value, newValue))}} public object () Receive () field reference consultant not leak object constVal = _value; return concert;}}
This is a ruthless path around the problem ... I just read the fields Can not, because I should be able to set it My what better solution?
updated: Thanks for the quick responses! It was correctly told that if I only return the _value then the context will be safe. I also want to change the view. If I allow changes outside of the nuclear context, then it defeats the whole purpose of creating this class ... is there a way to do this?
Even if you try, C # (without insecure code) or Java It is not possible to reverse the reference of a field in (I do not mean the context of an object)
You can just type return_value;
Your call-making fields will not be able to write.
/ div>
No comments:
Post a Comment