<Nullable>enable</Nullable>在我的專案定義中使用 NET 6我有:
if (!(await _context?.Applications.AnyAsync())) {
}
我得到提示“_context 在這里可能為空”,這就是我使用?它的原因。
我收到警告:
Dereference of a possibly null reference.
我也試過:
if (!(await _context?.Applications.AnyAsync()) ?? false) {
}
但這不能編譯。我該如何解決這個問題?
uj5u.com熱心網友回復:
嘗試這個:
if (_context != null && !(await _context.Applications.AnyAsync())) {
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/374016.html
標籤:C# asp.net核心 .net-6.0 c#-10.0
上一篇:在ASP.NETCore6中,為什么System.Private.ServiceModel.resources.dll的已發布輸出中需要語言檔案夾以及如何消除它們?
