- C# code
@{ViewBag.Title = "在线视频点播系统"; ViewBag.Location = "视频点播—首页"; }
- C# code
<div id="location"><strong>当前位置:</strong> @(ViewBag.Location ?? "视频点播") </div>
问题: @(ViewBag.Location ?? "视频点播") 这是什么意思, 中间2个 ??
------解决方案--------------------------------------------------------
??运算符
表示如果前面的为null,则取??后面的,否则保持原来的值,等价:
if (ViewBag.Location == null)
ViewBag.Location = "视频点播";
或者
ViewBag.Location = (ViewBag.Location != null) ? ViewBag.Location : "视频点播";