嘗試在 null 參考上存取成員(欄位/屬性/方法/索引器)。
Common Language Runtime Exceptions > System.NullReferenceException。執行時會在**拋出該行**自動中斷。null 的即為罪魁禍首。ViewBag/ViewData 未在 Controller 設值就直接在 View 取用。FindControl 回傳 null 卻直接 .Text。Include 載入(Lazy Loading 關閉時)。// C# 6.0+ null 條件運算子
var name = user?.Profile?.Name ?? "Guest";
// 或傳統判斷
if (obj != null) { obj.DoSomething(); }