Samstag, 8. Februar 2014

shorter term of exception handling with the help of the Ternary operator

For example:

catch (System.ServiceModel.FaultException<AnyContract.ValidationError> ex)
            {
                Console.WriteLine(ex.Detail != null ? ex.Detail.Message : ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }

or

catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }

Benefit from the best Windows Desktop app in the world and use Strokey.Net!