Results 1 to 3 of 3

Thread: try..finally

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    try..finally

    if i do just try and finally without any catch if an exception ocurrs it will be ignored or a ExceptionFound message will pop up?
    \m/\m/

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Doing this causes an error because it isn't caught:
    Code:
    try
    {
    	MessageBox.Show("hello");
    	throw new System.Exception("My exception");
    }
    finally
    {
    	MessageBox.Show("Here is the finally block");
    }

  3. #3
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    finally is optional.

    catch is not.

    If you don't want to catch the error, i.e. just ignore it, still put an empty catch:

    Code:
    try
    {
        //Statement that might generate error
    }
    catch
    {
    }
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width