I'm currently working with generic classes where I want to find all the overloaded operators of the underlying generic type.
Therefor I use simple reflection like typeof(T).GetMethods(bindingFlags)
and then filtering by methodInfo.isSpecialName
and methodInfo.Name.StartsWith("op_");
While dealing with primitive types like int and float I got really surprised:
For float I realized there are the rational operators (op_Equality
, op_Inequality
, op_Greater
etc..). But there are simply no arithmetic operators like op_Addition
, op_Subtraction
etc.
When I tried the same on int, I couldn't even find ration operators. And still no arithmetic ones in sight.
Is there any way to find those operators via reflection so I can treat those types like any other in my generic class? I simply want to generate a popup to choose from, including all operators (either rational or arithmetic).
The BindingFlags I combined using the |-operator
:
Instance, Static, Public, NonPublic, FlattenHierarchy
Thanks for any help in advance, greetings BOTHLine
Aucun commentaire:
Enregistrer un commentaire