Type: System.StringThe composite format string (see Remarks) to send to the Listeners collection. This message contains text intermixed with zero or more format items, which correspond to objects in the args array.

args

Type: System.Object[]An object array that contains zero or more objects to format.

This method uses the composite formatting feature of the .NET Framework to convert the value of an object to its text representation and embed that representation in a string. The resulting string is sent to the Listeners collection.

Typically, the Assert(Boolean, String, String, Object[]) method is used to identify logic errors during program development. Assert evaluates the condition. If the result is false, The String.Format(String, Object[]) method is called and the detailMessageFormat string and args array are passed in as parameters. Assert(Boolean, String, String, Object[]) then sends the specified text message and the formatted text message to the Listeners collection. You can customize this behavior by adding a TraceListener to, or removing one from, the Listeners collection.

When the application runs in user-interface mode, it displays a message box that shows the call stack with file and line numbers. The message box contains three buttons: Abort, Retry, and Ignore. Clicking the Abort button terminates the application. Clicking Retry sends you to the code in the debugger if your application is running in a debugger, or offers to open a debugger if it is not. Clicking Ignore continues with the next instruction in the code.

You can change the behavior of the DefaultTraceListener in the configuration file that corresponds to the name of your application. In this file, you can enable and disable the assert message box or set the DefaultTraceListener.LogFileName property. The configuration file should be formatted as follows: