C# !Conditional attribute?

First, having the Conditional attribute is not equivalent to having #if inside the method. Consider:

ShowDebugString(MethodThatTakesAges());

With the real behaviour of ConditionalAttribute, MethodThatTakesAges doesn’t get called – the entire call including argument evaluation is removed from the compiler.

Of course the other point is that it depends on the compile-time preprocessor symbols at the compile time of the caller, not of the method 🙂

But no, I don’t believe there’s anything which does what you want here. I’ve just checked the C# spec section which deals with conditional methods and conditional attribute classes, and there’s nothing in there suggesting there’s any such mechanism.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)