为什么 getter for Exception.HResult 不再受保护?
Why is the getter for Exception.HResult no longer protected?
从 .NET 4.5 开始,Exception.HResult
的 getter 现在是 public
,但以前是 protected
。
来自 MSDN:
Starting with the .NET Framework 4.5, the HResult property's setter is protected, whereas its getter is public. In previous versions of the .NET Framework, both getter and setter are protected.
我们知道为什么要进行此更改吗?
In .NET 4.5, the HResult
property getter is now Public
, so you do not have to use Marshal.GetHRForException
(along with its side affects) anymore.
来源:How to check if IOException is Not-Enough-Disk-Space-Exception type?
从 .NET 4.5 开始,Exception.HResult
的 getter 现在是 public
,但以前是 protected
。
来自 MSDN:
Starting with the .NET Framework 4.5, the HResult property's setter is protected, whereas its getter is public. In previous versions of the .NET Framework, both getter and setter are protected.
我们知道为什么要进行此更改吗?
In .NET 4.5, the
HResult
property getter is nowPublic
, so you do not have to useMarshal.GetHRForException
(along with its side affects) anymore.
来源:How to check if IOException is Not-Enough-Disk-Space-Exception type?