J
J055
Hi
I understand that a throw statement throws an exception immediately and
unconditionally. Control never reaches the statement immediately following
the throw. The following method seems to stop the statements (if
Enum.IsDefined is false) after the throw and return null to the calling
proceedure. Then the calling proc raises a NullReferenceException. Basically
it looks to me like the throw statement is not stopping the programme
immediately. Can this be true or have I missed something?
public int AddAccount(...byte accountType...)
{
// Check that a valid account type exists as an AccountType Enum
if (!Enum.IsDefined(typeof(AccountTypes), accountType))
throw new ArgumentOutOfRangeException("AccountType must have a matching
Enum.");
....
// do some db inserting
// Add the new account
return account.AccountID;
}
Many thanks
Andrew
I understand that a throw statement throws an exception immediately and
unconditionally. Control never reaches the statement immediately following
the throw. The following method seems to stop the statements (if
Enum.IsDefined is false) after the throw and return null to the calling
proceedure. Then the calling proc raises a NullReferenceException. Basically
it looks to me like the throw statement is not stopping the programme
immediately. Can this be true or have I missed something?
public int AddAccount(...byte accountType...)
{
// Check that a valid account type exists as an AccountType Enum
if (!Enum.IsDefined(typeof(AccountTypes), accountType))
throw new ArgumentOutOfRangeException("AccountType must have a matching
Enum.");
....
// do some db inserting
// Add the new account
return account.AccountID;
}
Many thanks
Andrew