Share via


ExtraTopLevelOperators.eprintf<'T> Function (F#)

Print to stderr using the given format.

Namespace/Module Path: Microsoft.FSharp.Core.ExtraTopLevelOperators

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
eprintf : TextWriterFormat<'T> -> 'T

// Usage:
eprintf format

Parameters

Remarks

This function is named PrintFormatToError in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

Example

The following code example demonstrates the use of eprintf.

let maxValue = 10
let function1 x =
   if (x > maxValue) then
       eprintf "Error: the input %d exceeds the maximum value, %d." x maxValue
   else
       printfn "Success!"
function1 1
function1 11
// Issue a newline to stderr to trigger printing.
stderr.WriteLine()

The output is as follows.

Success!
Error: the input 11 exceeds the maximum value 10.

Platforms

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Core.ExtraTopLevelOperators Module (F#)

Microsoft.FSharp.Core Namespace (F#)