One way that might be applicable is to use namespace aliases. You use an alias instead of the actual type and a compiler directive to switch between them. Because namespace aliases are for each file, this may not be acceptable if the code is distributed across multiple files.
#if GDI using Point=System.Drawing.Point; #else using Point=System.Windows.Point; #endif
If you use var , you can eliminate many checks, throws and maintain performance. You still have to look for functions that accept and return certain types, such as Math.Sin etc
source share