Is it possible to get the errornumber in C#?

I have made a C# project and i put try en catch around the functions to do the error-handling. When an error is thrown i call a function, with Exception exc as an argument, to get the same errorpage every time an error is thrown.
In visual basic it was possible to get the number of the error that was thrown by: Err.Number
My question is whether this is possible in C# too? And how do you do this? Because the Exception exc hasn't got a property to do it.




  • Yes, you can get the errorcode from the Exception, but you have to use innerexception except the Base Exception.

    some code here....
    catch(System.Data.SqlClient.SqlException ex)
    MessageBox.Show("this is Sql Exception");
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion