Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • I totally agree, but if I choose to use debug.assert and code contract on the same place should it be in certain order? Commented Dec 16, 2013 at 4:58
  • Not sure why you would do a double check in that manner. Order shouldn't manner. If I were doing that I believe I'd put the Debug.Assert first as a development debugging aid. Commented Dec 16, 2013 at 14:29
  • Debug.Assert will not be there in Release code, but code contracts will. So I feel there are cases where debug.assert will be needed in parallel with Code contracts- I might be wrong. Hence the question. Commented Dec 16, 2013 at 15:09
  • 3
    True, but the code contract will detect the issue it both debug and release. If you make sure to break on code contract exceptions you have the same effect without the need for the Debug.Assert. One could make a case that having a debug.Assert in addition to code contract does provide a double check for maintenance (Asserts are hard to ignore :-)) Commented Dec 20, 2013 at 22:48
  • 9
    Not to be forgotten: "Use the Trace.Assert method if you want to do assertions in release builds." (msdn.microsoft.com/en-us/library/tk4kachs(v=vs.110).aspx) Commented Aug 21, 2014 at 20:45