samedi 18 août 2018

How to safely get the a particular base type of a control?

I have a user control A which inherits from a concrete base type B which in turn inherits from a generic control C.

I need to check if A inherits from C and currently I'm doing the following:

var cType = typeof(C<>);
var aType = typeof(A);

if (aType.BaseType.BaseType?.FullName == cTye.FullName) {}

The above works but I was wondering if there's a cleaner way to do this?





1 commentaire: