IS4
IS4
I am afraid I don't know of a usable library for that, but I wish you good luck on solving this!
It's a good point that there are these methods to use, but there also situations where you might not want to produce an exception, or the existing guard methods don't...
@hez2010 Good point! It would be better to disable `P` from changing the type of the result in that case.
Actually, to provide more thoughts, the reasoning behind `as T and P` was intended primarily to make something like `as IComparable and > 10` turn into `int?` (since `> 10`...
@bbarry Yes, #8207 is what this started as.
@Thaina I don't like it either, but that is how patterns work in general ‒ `x is >= 0` checks for `int`.
@glen-84 > ```cs > obj as >= 0 > ``` "Treat `obj` *as* something non-negative." There is nothing that says "`null` on failure" in that sentence, but you don't get...
Unless `null` is in the accepted set of values, in which case `??` would filter it out. Something like `str as null or ""` alone should probably be a warning...
This seems to be especially useful for structs, as calling an explicit interface implementation via a base lookup would remove the need for boxing to the specific interface type, and...
@gafter I was referring to this case: ```cs struct Struct : IEnumerable { public IEnumerator GetEnumerator() { yield break; } IEnumerator IEnumerable.GetEnumerator() { yield break; } public IEnumerator GetNonGenericEnumerator() {...