All,
Is it possible to invoke operators (such as +, ++) via reflection on built-in types in .net 2.0?
It appears, you can’t! When I tried to access op_Increment on int32, the operator was not defined. I read that operators on built-in types are handled by the compiler and are not defined on the actual type … please confirm.
Otherwise, is there another way? I know later version of C# has dynamic keyword, what are my options?
No, you can’t. On the built in types (bool, byte, short, int, long, float, double) operations like
+and++are mapped to IL instructions and don’t have a correspondingop_Incrementmethod, for example.decimaldoes allow you to, even though it looks like a built-in type.stringis an interesting one as calls to+are mapped toString.Concatand its variants.Take a look at this generic operators article, it may help (it’s by Jon Skeet and Marc Gravell)