Wrox Programmer Forums
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2008, 08:48 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Default _DEBUG_

I have seen this sort of thing in old MFC procgrams in C++ and I wonder what is the comparable way to do this in C#.

If I want a C# program to run differently in debug mode than in release mode, how do I do it? Don't I use some sort of #ifdef _DEBUG_ command?
 
Old December 30th, 2008, 09:09 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

There are two ways to do this in C#.

The first:
c# Code:
#if DEBUG
public string foo()
{
    return "foo";
}
#endif
 

The other way is:

c# Code:
[Conditional("DEBUG")]
public static void DoSomething()
{
    //Do something here
}

There are significant differences between the two but rather than bore you with it here, you can read an pretty good article that explains the two here: http://www.thinkfarahead.com/2007/09...nditional.html

hth
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.