C#可以創建自己的擴展方法Extension Method:
參考這篇《判斷是否為空然后賦值》http://www.cnblogs.com/insus/p/8004097.html
里,前面三個方法,均出現null這關鍵詞,在判斷時,你需要== null或者!=null。
其實你完全可以創建C#的擴展方法來消除這種的繁雜。

public static class ExtensionMethod { public static bool IsNull(this object obj) { return obj == null; } public static bool IsNotNull(this object obj) { return obj != null; } }

result = str.IsNull() ? "" : str; result = str.IsNotNull() ? str : "";