Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# using Conditional() with an environment variable

How do I use Conditional("Condition1") attribute where "Condition1" is an environment variable. The help says it can be done but does not say how?

like image 878
Kaya Avatar asked May 05 '10 14:05

Kaya


1 Answers

I believe this is what you are looking for http://yogesh.jagotagroup.com/blog/post/2008/03/01/CSharp-Conditional-attribute.aspx

The word 'environment variable' refers to VS environment, not the OS or any other. You can simply tag your classes or methods with DEBUG or any custom variable; then, these classes and methods still exist when compiled, but when IL code is generated, they are simply skipped - in case that variable is not defined (like the example says).

Hope this helps.

Pz, the TaskConnect developer

like image 87
Pz. Avatar answered Sep 28 '22 10:09

Pz.