3 ms·
You don't need it for reference types, because those can just return a null. I agree that it would be nice if C# checked that you dealt with the null case of t
by AndrewDucker 12y ago
You don't need it for reference types, because those can just return a null.
I agree that it would be nice if C# checked that you dealt with the null case of the return - Resharper will happily warn me if I haven't, but it would be nice if the base compiler did. Maybe in the future!
- Arnavion 12y ago>You don't need it for reference types, because those can just return a null. The point is that it is not necessarily correct to conflate the nullability of the parse with the correctness of the parse. If I wanted to parse a string into a Foo, null might be a valid value for a successful parse to return, say because the rule is that the string "(null)" maps to a null Foo.
- danbruc 12y agoThere is a draft for pattern-matching in C# [1]. [1] https://roslyn.codeplex.com/discussions/560339 https://roslyn.codeplex.com/discussions/560339