Different types in release and debug in C# -


i've got performance / memory critical code uses floats. in debug mode i'd use decimals, makes easier verify calculations correct.

obviously do:

#if debug         decimal x; #else         float x; #endif 

it involve doing in numerous places, , seems bit cumbersome. wondering if there better way? can't create own type descends 1 or other depending on build settings, they're sealed classes. don't want casting left right , centre, said before, it's performance critical.

i want able say.

#if debug         mytype = decimal; #else         mytype = float; #endif  mytype x; 

any suggestions appreciated.

using system; #if debug using mytype = system.decimal; #else //float using mytype = system.single; #endif 

you can define type using using keyword , use it:

mytype x = 19.2; mytype y = 19.2; mytype d = x + y; 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -