CS8121: Custom <T> cannot be processed by pattern type 'T'
Given the following code:
struct Custom<T> where T : struct { }
//...
Nullable<int> x = 2;
if(x is int z) { } //compiles
Custom<int> a = 2;
if(a is int b) { } //CS8121 An expression of type 'Custom<int>' cannot be handled by a pattern of type 'int'.
What allows you to Nullable<T>
process the template T
? Can I do the same for my custom structure? I already tried conversion operators, but no luck. Not sure if I tried all possible operators.
+4