使用变量外部switch语句+ asp.net mvc

 mobiledu2502861197 发布于 2023-02-08 20:52

在我的控制器中的索引操作中,我有:

public ActionResult Index(string sortOrder)
{
    var model;
    ViewBag.CitySortParm = String.IsNullOrEmpty(sortOrder) ? "City_desc" : "";
    switch (sortOrder)
    {
        case "City_desc":
            model = this.UnitOfWork.AddressRepository.Get().OrderBy(a => a.City);
            break;
    }
    return View(model);
}

这不起作用,我总是得到错误: Implicitly-typed local variables must be initialized

为什么这不起作用,我该如何解决这个问题呢?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有