---
title: "How do I create a MessageBox in C#?"  
description: "How do I create a MessageBox in C#?"  
author: "Anonymous User"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1481/how-do-i-create-a-messagebox-in-c-sharp  
category: "wpf"  
tags: ["messagebox", "mindstick", "winform", "MessageBox in C#", "window form application"]  
reading_time: 1 minute  

---

# How do I create a MessageBox in C#?

I have just installed C# for the first time, and at first glance it appears to be very similar to VB6. I decided to start off by [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to make a 'Hello, [World](https://yourviews.mindstick.com/view/87468/defining-humanity-as-given-in-sanatan-dharma-best-in-world)!' UI Edition.

I started in the Form Designer and made a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) [named](https://answers.mindstick.com/qa/44918/what-is-a-no-day-yet-named-motion) "[Click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) Me!" proceeded to double-click it and [typed](https://www.mindstick.com/interview/33645/what-is-the-difference-between-typed-and-untyped-dataset) in

MessageBox("Hello, World!");

I received the following [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing):

MessageBox is a 'type' but used as a '[variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation)'

Fair [enough](https://answers.mindstick.com/qa/48601/who-is-the-writer-of-the-one-life-is-not-enough), it seems in C# MessageBox is an Object. I tried the following

MessageBox a = new MessageBox("Hello, World!");

I received the following error: MessageBox does not contain a constructor that takes '1' [arguments](https://answers.mindstick.com/qa/92535/what-are-the-different-types-of-arguments)

Now I am stumped. Please help.

## Replies

### Reply by Sumit Kesarwani

Hi Ashish,\

MessageBox.Show also returns a DialogResult, which if you put some buttons on there, means you can have it returned what the user clicked. Most of the time I write something like

```
if (MessageBox.Show("Do you want to continue?",
"Question", MessageBoxButton.YesNo) == MessageBoxResult.Yes) {     //some
interesting behaviour here}
```


---

Original Source: https://www.mindstick.com/forum/1481/how-do-i-create-a-messagebox-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
