Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conditional Compilation
Message
De
13/01/2009 00:51:30
 
 
À
12/01/2009 17:29:14
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01372770
Message ID:
01373080
Vues:
19
>>>>You can also test for debug mode
>>>>
>>>>if (System.Diagnostics.Debugger.IsAttached)
>>>>{
>>>>     DoSomething()
>>>>}
>>>>else
>>>>{
>>>>     DoSomethingElse()
>>>>}
>>>>
>>>
>>>I didn't know that. But now that I do I'm having trouble seeing a use for it.....

>>
>>
>>I use that occasionally for error messages. IOW, an error message that gets displayed to the user at runtime might be an abbreviated version of the error message displayed to the developer during debugging.
>
>OK. But conditional compilation can do that. Using this it feels that I would be compiling/shipping surplus production code. i.e. if you're going to be around to debug it then why not just run a debug version.......

I would also use conditional compilation over the if statement, I go as far as doing this for the design mode test:
#if DEBUG
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
#endif
  {
  ///Some code that I don't want in design mode.
  }
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform