Quantcast
Channel: Odyssey to knowledge » C# .Net 2.0 Techniques
Viewing all articles
Browse latest Browse all 9

C# Exception Facts

$
0
0

What is an Exception

Popular misconception , Exception does not mean Error Handling …..

When an type’s action member cannot complete its task, the member should throw an exception. An exception means that an action member failed to complete its task it was supposed to perform indicated by its name.

internal class Account {

     public static void Transfer(Account from, Account to , Decimal amount) { … }

}

Here is for some reason Transfer cannot happen then it should throw an exception.

What’s the order of inner finally when an exception occurs on an outer try block.

   CLR  first locates the catch block with a matching catch type, it executes the code in the inner finally blocks, starting from within the try block whose code threw the exception and stopping with the catch block that matched the exception.

     Note that any finally block associated with the catch block that matched the exception is not executed yet. The code in this finally block won’t execute until after the code in the handling catch block is executed.

What happens if code in finally block throws an exception.

      CLR will not keep track of the first exception.

Whats difference between

try{ … }

catch(Exception e)

{

throw e; // CLR resets the starting point of exception to here

}

catch(Exception e)

{

throw; //CLR will keep the original location of exception

}

Why sometimes actual call stack don’t appear in the stack trace string

JIT compiler can inline method


Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images