Alternative to #define

  • Thread starter Thread starter Srikanth
  • Start date Start date
S

Srikanth

Hello
I wrote a very efficient way for getting debugging information in vc using
#define tr(str) tr(str,...)

But in C Sharp it #define doesnt allow me to assign a value to #define macro
Please let me know, if an alternative exists for the same
Regards
Srikanth
 
Srikanth said:
Hello
I wrote a very efficient way for getting debugging information in vc using
#define tr(str) tr(str,...)

But in C Sharp it #define doesnt allow me to assign a value to #define macro
Please let me know, if an alternative exists for the same
Regards
Srikanth

The magic of the pre-processor doesn't exist in C#. You will have to resort to
managed C++ or come up w/ another way to do it.
 
Not sure exactly what you're trying to do but what about the built-in .NET Debug/Trace message facilities

using System.Diagnostics

...

Debug.Writeline("This debug message will only appear in debug builds.")
Trace.Writeline("This trace message will appear in debug & release builds.")

--Richar
 
Srikanth,

In addition to what the other posters said about using the Debug class,
you can also use the Contitional attribute on a method to keep it from being
called when certain environment variables are not defined. For example, you
can have a logging method that will only be run when the "TRACE" or the
"DEBUG" variables are defined. For more info, check the about section of
the ConditionalAttribute in the .NET framework documentation.

Hope this helps.
 
Back
Top