[Proposal] allow is operator compare generic type #3432
Replies: 5 comments
-
@leandromoh Why would it be amazing to be able to do |
Beta Was this translation helpful? Give feedback.
-
Note these are not equivalent. |
Beta Was this translation helpful? Give feedback.
-
@YairHalberstadt yes, you are right about what the proposal means. I will fix the summary @jnm2 it would avoid boilerplate code (like use |
Beta Was this translation helpful? Give feedback.
-
@YairHalberstadt @leandromoh IsAssignableTo is in API review, hasn't been shipped: dotnet/runtime#30714 @leandromoh I was going to disagree that |
Beta Was this translation helpful? Give feedback.
-
@jnm2 Yes, when dealing with generics and metaprogramming (like a lot of libraries does) comparing types is a common task. so should be nice to simplify theses cases:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
as well we can do
x is string
to check if the instancex
is of typestring
, would be amazing extend this behaviour to generic types, likeT is string
.T is SomeType
would be equivalent totypeof(T).IsAssignableTo(SomeType)
Beta Was this translation helpful? Give feedback.
All reactions