Best way to check for inner exception?

.net, c#, exception

Solution

Is this what you are looking for?

String innerMessage = (ex.InnerException != null) 
                      ? ex.InnerException.Message
                      : "";

Problem

I know sometimes innerException is null So the following might fail: ``` repEvent.InnerException = ex.InnerException.Message; ``` Is there a quick ternary way to check if innerException is null or not?

Original source

Related problems