The instance is passed by reference. The pointer to the instance is passed by value.
If you use ref , the pointer is also passed by reference - so you can use:
private void CustomDispose(ref object x) { x.Dispose(); x = null; } CustomDispose(ref someInstance.someField);
someInstance field will be set to null. This can be useful in Disposing using a custom method, for example.
source share