【发布时间】:2014-07-20 11:58:04
【问题描述】:
没关系:
(bool)TempData["sortBool"]
这样不行:
TempData["sortBool"] as bool
错误表明:
Error 1 The as operator must be used with a reference type or nullable type ('bool' is a non-nullable value type) C:\Users\xye15\Desktop\CodeChallengeV4\CodeChallengeV4\MovieKiosk\Controllers\HomeController.cs 55 21 MovieKiosk
我明白为什么第二个是错误的,就像错误消息一样。但是我很困惑为什么编译器不抱怨第一个。 谢谢!
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 tempdata