---
title: "Exception message not working"  
description: "Exception message not working"  
author: "Takeshi Okada"  
published: 2013-12-23  
updated: 2013-12-23  
canonical: https://www.mindstick.com/forum/1833/exception-message-not-working  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Exception message not working

```
public partial class Form1 : Form{    public Form1()    {        InitializeComponent();    }    private void button1_Click(object sender, EventArgs e)    {        try        {            string[] names = new string[2];            string g = names[2];        }        catch(Exception error) {            MessageBox.Show(error);        }    }}
```

I don't know what’s [wrong](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) with it can’t seem to find the [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing). It would [helpful](https://yourviews.mindstick.com/view/81752/oximeter-for-covid-patients-is-helpful-tool) if you could help me?

## Replies

### Reply by Pravesh Singh

Hi Takeshi,

There is no overload of Show which accepts an Exception as a parameter. You probably want to show the exception's Message property:

```
try{    string[] names =new string[2];    string g =names[2];}catch(Exception error) {   
MessageBox.Show(error.Message);}// Index was outside the bounds of the array.Or possibly call ToString, which will typically provide you
with a little more information than just the Message:try{    string[] names =new string[2];    string g =names[2];}catch(Exception error) {   
MessageBox.Show(error.ToString());}
```


---

Original Source: https://www.mindstick.com/forum/1833/exception-message-not-working

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
