Tuesday October 6th

Monday October 5th

1 Kicks

C# Snippet - Using the Conditional Attribute

You probably know about methods like Debug.WriteLine and Debug.Assert. A big part of their use is that they only do stuff if you are running a application compiled in Debug mode. If you are running in release mode, however, its like those calls in your code don't even exist - this way you can feel free to put helpful debug messages and checks in your code without worrying about the release version of the application being affected. Have you ever wondered how this is done? Well, what happens in the end is that those calls really don't exist in a release compiled version of an application - they are literally ripped out of the code. But there is no magic going on here, and nothing that is specially restricted to Microsoft's own code - its actually just a plain old method attribute, one that we can use in our own code if we wanted to.


Commenting on Stories is limited for now and will open up to those recommended by the community. Learn how
Loading DotNetKicks...
brought to you by the Kicks Network