This is a discussion on Trace and Assert within the C# Programming forums, part of the Software Development category; Hui guys can anyone tell me How do I do implement a trace and assert?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| hey, Use a conditional attribute on the method, as shown below: class Debug { [conditional("TRACE")] public void Trace(string s) { Console.WriteLine(s); } } class MyClass { public static void Main() { Debug.Trace("hello"); } } In this example, the call to Debug.Trace() is made only if the preprocessor symbol TRACE is defined at the call site. You can define preprocessor symbols on the command line by using the /D switch. The restriction on conditional methods is that they must have void return type.
__________________ Venkat knowledge is Power |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Debug class and Trace class | simplesabita | Software Testing | 3 | 08-18-2007 12:30 AM |
| Trace files and Log Files in Unix | vigneshgets | Operating Systems | 0 | 08-01-2007 05:18 AM |
| how it helps to increase the performance in asp .net Set trace enabled="false" | oxygen | ASP and ASP.NET Programming | 1 | 07-20-2007 06:28 AM |
| Trace | trace | Introductions | 0 | 07-20-2007 05:08 AM |
| Assert | raj | PHP Programming | 1 | 07-16-2007 09:40 AM |