3 ms·
This page[1] (which was linked elsewhere in the thread) provides the following info: > Since an expression needs to either have a value or throw an exception,
by dgritsko 8y ago
This page[1] (which was linked elsewhere in the thread) provides the following info:
> Since an expression needs to either have a value or throw an exception, a switch expression that reaches the end without a match will throw an exception. The compiler does a great job of warning you when this may be the case, but will not force you to end all switch expressions with a catch-all: you may know better!
I haven't used the feature yet myself, so I can't say it definitively - but it sounds like it does provide compile time feedback while still allowing you to compile.
[1]: https://blogs.msdn.microsoft.com/dotnet/2019/01/24/do-more-with-patterns-in-c-8-0/ https://blogs.msdn.microsoft.com/dotnet/2019/01/24/do-more-w...
- platz 8y agoit sounds like it does a "best effort" and then gives up, unfortunately, the article doesn't describe exactly to what lengths it goes here.
- Mindless2112 8y agoSpecifically, it will throw SwitchExpressionException[1] [1] https://github.com/dotnet/corefx/issues/33284#issuecomment-448332714 https://github.com/dotnet/corefx/issues/33284#issuecomment-4...