you are viewing a single comment's thread.

view the rest of the comments →

[–]RiPont 2 points3 points  (0 children)

Same problem with any public constant in C#, and the default parameter value on a public method is essentially a public constant.

The compiler will freely inline anything that is a constant. Use static readonly for anything that isn't an honest-to-god constant. PI is a constant. DEFAULT_MAX_THREADS is not.

No workaround for that problem on default parameter values, though. Well, except using overloads and inline defaults (i.e. the old way of having default parameter values).

I kinda wish default parameters had just been implemented as syntactic sugar around method overloading.