G
Guest
I have a method that gets an LdapException. It calls a method that receives an Exception object.
After checking via GetType().FullName and verifying that the object is in fact an LdapException, I want to cast it back to an LdapException.
Can I do that? How do I do that?
Code snippet:
Method1
{
try
{
someFunc();
}
catch (LdapException e)
{
PrintError(e);
}
}
PrintErr(Exception e)
{
switch (e.GetType().FullName)
{
case ("LdapException"):
LdapException x = (LdapException)e; <throws an InvalidCastException>
break;
default:
...
}
}
- Bruce
After checking via GetType().FullName and verifying that the object is in fact an LdapException, I want to cast it back to an LdapException.
Can I do that? How do I do that?
Code snippet:
Method1
{
try
{
someFunc();
}
catch (LdapException e)
{
PrintError(e);
}
}
PrintErr(Exception e)
{
switch (e.GetType().FullName)
{
case ("LdapException"):
LdapException x = (LdapException)e; <throws an InvalidCastException>
break;
default:
...
}
}
- Bruce