C# Programming - Exception Handling - Discussion

Discussion :: Exception Handling - General Questions (Q.No.12)


Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor.

[A]. True
[B]. False

Answer: Option A


No answer description available for this question.

Jagdish said: (Jun 11, 2012)  
Yeah its true cause constructor can not return error code.

Andrue Cope said: (Oct 27, 2013)  
By the strict definition of 'return' then no. CTors can't return values. However they can have ref or out parameters so in the wider sense they can pass an error code back to the caller:

class wibble
public wibble(out int errorCode)

It's dodgy practice though.

Steve said: (Feb 26, 2014)  
public class MyCustomException : Exception

: base("Here is a string describing exception")
//something else here.

Rohit said: (Sep 21, 2016)  
Still Unable to understand. Can anyone explain with simple example?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.