1

As of .NET 4.5, the getter for Exception.HResult is now public, but it used to be protected.

From 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.

Do we know why this change was made?

Richard Ev
  • 52,939
  • 59
  • 191
  • 278
  • 1
    It seems like an oversight that it hadn't been done earlier which they now rectified. At least it makes sense to me that it's public rather than protected. – Jeroen Vannevel Feb 13 '15 at 16:59
  • @JeroenVannevel A [13-year](http://en.wikipedia.org/wiki/.NET_Framework_version_history#.NET_Framework_1.0) oversight! :) – Richard Ev Feb 13 '15 at 17:05

1 Answers1

3

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.

Source: How to check if IOException is Not-Enough-Disk-Space-Exception type?

Community
  • 1
  • 1
Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123