C# Programming - Exception Handling - Discussion

Discussion Forum : Exception Handling - General Questions (Q.No. 12)
12.
Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Jagdish said:   1 decade ago
Yeah its true cause constructor can not return error code.

Andrue Cope said:   1 decade ago
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:   1 decade ago
public class MyCustomException : Exception

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

Rohit said:   9 years ago
Still Unable to understand. Can anyone explain with simple example?

Post your comments here:

Your comments will be displayed after verification.