Condividi tramite


MessageBox.Show Method (String)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Displays a message box that contains the specified text and an OK button.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Shared Function Show ( _
    messageBoxText As String _
) As MessageBoxResult
public static MessageBoxResult Show(
    string messageBoxText
)

Parameters

Return Value

Type: System.Windows.MessageBoxResult
OK in all cases.

Exceptions

Exception Condition
ArgumentNullException

messageBoxText is nulla null reference (Nothing in Visual Basic).

Remarks

The message box is modal, which means that the user must click OK or press ESC to dismiss the message. In both cases, the return value is the same.

Examples

The following example code demonstrates how to use this method.

MessageBox.Show("No caption, one button.")
MessageBox.Show("No caption, one button.");

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.