检查内部异常的最佳方法

检查内部异常的最佳方法

本文介绍了检查内部异常的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有时innerException是null

I know sometimes innerException is null

所以以下可能会失败:

 repEvent.InnerException = ex.InnerException.Message;

有一个快速的三元方法来检查innerException是否为空?

Is there a quick ternary way to check if innerException is null or not?

推荐答案

这是你要找的?

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

这篇关于检查内部异常的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 01:52