|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Newbie Q - debug or trace?Hi,
as a newbie to C# I was not clear on the difference and usage of the trace and debug classes. I know how to use them and the debug.assert method seems very akin to unit testing practices. They seem very similar to me - are they? is it something to do with implementation on the CLR level or do they indeeed have different 'logical' uses? Thanks Charlie CharlieOz1 wrote:
> Hi, The only real difference between the debug and trace classes is that the> as a newbie to C# I was not clear on the difference and usage of > the trace and debug classes. > > I know how to use them and the debug.assert method seems > very akin to unit testing practices. > > They seem very similar to me - are they? is it something to > do with implementation on the CLR level or do they indeeed > have different 'logical' uses? > > Thanks > Charlie > debug class only works if you compile in debug mode. If you compile in release mode Debug.WriteLine() won't do anything. I haven't used Debug.Assert in .net, but I have seen asserts commonly used in C/C++ programs. It's purpose was to check that a condition was valid at runtime and if not exit the program printing a file name, line number, and some other information. -David Hi,
David has already cited the main difference between Debug and Trace. Applying a broader perspective, I would say that Debug is more useful during the development phase (when you're working in the Debug compilation mode) of a project, while Trace is more useful during the Maintenance phase (when your project has been released and deployed at the client). Using Trace in this condition allows you to keep getting and storing diagnostic information about program crashes, or exceptions generated. Also note that Debug.Asserts checks for a condition to be *false*. Only then it outputs to the call stack. Regards, Cerebrus. |
|||||||||||||||||||||||