Solved

exception handling

Posted on 2009-06-27
5
190 Views
Last Modified: 2013-12-14
I am using visual studio 2008 - C#
I am trying to use code with ex.Message
intellisense does not recognize ex - I see exception
Should I be able to use ex as code in C#?
thank you
0
Comment
Question by:davetough
5 Comments
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 50 total points
ID: 24727405
can you share your code
0
 

Author Comment

by:davetough
ID: 24727431
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace labOne
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int myTotal = Int16.Parse(textBox1.Text);
            }
            catch
            {
                MessageBox.Show("error":, ex.Message");
            }

        }
    }
}
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 250 total points
ID: 24727443
catch (Exception ex)
0
 

Author Comment

by:davetough
ID: 24727465
if i understand correctly - i insert it here
  try
            {
                int myTotal = Int16.Parse(textBox1.Text);
            }
            catch (Exception ex)  //HERE

            {
                MessageBox.Show("error":, ex.Message");                 }
0
 
LVL 11

Assisted Solution

by:saragani
saragani earned 200 total points
ID: 24727712
You understand correctly.

You can also catch by exception type:

            try
            {
                int myTotal = Int16.Parse(textBox1.Text);
            }
            catch (IOException ex)
            {
                MessageBox.Show("error":, ex.Message");
            }
            catch (UserDesignedException ex)
            {
                MessageBox.Show("error":, ex.Message");
                // Do some code here if you need
            }
            catch (Exception ex)
            {
                MessageBox.Show("error":, ex.Message");
            }
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now