I am learnig CSharp.I have some doubts in handling exceptions.Kindly guide me to improve my coding knowledge.
Suppose i construct a code segment :
try {
SomeWork();
return success;
}
catch (someException ex)
{
throw new ExceptionDetails(ex);
return failure;
}
catch(AnotherException exp)
{
throw new ExceptionDetails(exp);
return failure;
}
finally
{
CleanUpStuff();
}
Questions:
(1) Can i use return statement after "throw" (throwing exception) ?
(2) Is throwing an exception ugly practice?.When exactly do i need to throw an exception?Do i need to use "throw" to report only custom exception ?
(3)
try
{
SomeWork();
}
catch(StringIndexOutOfBound ex)
{
throw;
}
using anonymous throw statement inside catch is a good practice?