Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:02:46+00:00 2026-05-26T23:02:46+00:00

I assume I’m missing something really trivial here but for reason it’s not obvious

  • 0

I assume I’m missing something really trivial here but for reason it’s not obvious to me. I’ve always assumed that “finally” always executes, regardless of an exception or not.

Anyway, this code failed to run and I’m not sure why. It gets to i = i/j and throws an DivideByZero exception but I would’ve thought it would continue and execute the finally statement before stopping.

static void Main(string[] args)
{
    int i = 1;

    try
    {
        int j = 0;
        i = i / j;

        Console.WriteLine("can't get");
    }
    finally
    {
        Console.WriteLine("finally ran");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:02:47+00:00Added an answer on May 26, 2026 at 11:02 pm

    Take a look at this MSDN try-finally (C# Reference)

    From above link:

    Usually, when an unhandled exception ends an application, whether or
    not the finally block is run is not important. However, if you have
    statements in a finally block that must be run even in that situation,
    one solution is to add a catch block to the try-finally statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume that we have two sets: A=(a_1,a_2,...,a_m) and B=(b_1,b_2,...,a_n) (Not necessarily of same size).
Assume that I have such entities like the following: @Document(collection = doc_a) public class
assume my table contains following columns Roll_number numeric not null Subject1 varchar(40) null Subject2
Assume in the below code that there is a match for #bob and #test,
Assume you have a Question and an Answer models, and that new answers are
Assume that there are two tables in a database. First one is X, second
Assume that you have at most 100 elements in which their types and format
Assume 200,000 images in a flat Amazon S3 bucket. The bucket looks something like
Assume I have a static generic class. Its generic type parameters are not available
Assume that my delete tries to rebalance the tree inorder (left to right). I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.