lundi 19 novembre 2018

Check if type is assignable from generic constraints

I need to determine if System.Type is assignable from list of generic constraints at runtime.

// Example
Type type = typeof(int);

// Generic constraints to check
// unmanaged, IComparable, IFormattable, IConvertible, IComparable<T>, IEquatable<T>

bool isAssignable = IsAssignable(type);





Aucun commentaire:

Enregistrer un commentaire