What benefit does the new “Exception filter” feature provide?
问题 C# 6 has a new feature called "exception filtering" The syntax is like this: catch (Win32Exception exception) when (exception.NativeErrorCode == 0x00042) { //Do something here } I couldn't help but wonder what the benefit of that is over the current approach: catch (Win32Exception exception) { if (exception.NativeErrorCode == 0x00042) { //Do something here } } Is it a big deal that filtering happen before the curly bracket? Perhaps in relation to performance or security? 回答1: The Exception