在 Xamarin.Android 中调用 Dispose 或设置为 "default" 有什么区别?

What is the difference between calling Dispose or setting to "default" in Xamarin.Android?

我继承了在 OnDestroy() 中将视图元素设置为默认值而不是在所有 Fragment 中调用 Dispose() 的代码。这些方法有什么区别between/impact?

例如

    public override void OnDestroy()
    {
        ClearViewElements();

        base.OnDestroy();
    }

    private void ClearViewElements()
    {
        _aRecyclerView.RemoveAllViewsInLayout();
        _aRecyclerView.SetAdapter(null);
        if (_aListAdapter != null)
        {
            _aListAdapter.DeleteClick = default;
            _aListAdapter = default;
        }
        _aRecyclerView = default;
        _aButton = default;
        _anEditText = default;
        _aLayout = default;
    }

default 只会将值设置为对象默认值,应该是 null

假设为null,这与Dispose有相似之处,但又不相同。由于该对象不应该再有任何引用(有一些注意事项,比如如果所有订阅都被清除)它可用于垃圾收集并且最终应该被收集。但是,使用 Dispose 标记该对象应该被收集,因此应用程序从那一刻起就知道这一点,而不是从检查免费引用的那一刻起。