In C#, given two input Type
s, it it possible to determine the output Type
and implicit upcast Type
s for an operator? For example, consider the expression s + i
. Say I have the following information:
short s;
int i;
Type leftType = typeof(short);
Type rightType = typeof(int);
Can I determine the following information about the expression s + i
?
Type leftUpcastType = typeof(int);
Type rightUpcastType = typeof(int);
Type outputType = typeof(int);
I obviously could do this with an enormous lookup table of all the types and operators, but there might be an easier way. Ideally this would work for user-defined classes with operator overloads too, but that is a secondary requirement.
Aucun commentaire:
Enregistrer un commentaire