C# Snippet - Using the Conditional Attribute(switchonthecode.com)

submitted by crpietschmanncrpietschmann(11.3k) 3 years, 1 month ago

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.

add a comment |category: |Views: 17

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story