页面是什么?1具体做了什么 [英] What does page?1 does specificely

查看:83
本文介绍了页面是什么?1具体做了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码

 public ActionResult commenter(int?page)
{
List < comment > c = db.comments.ToList ();
int pageSize = 3;
int pageNumber =(page ?? 1);
返回视图(c.ToPagedList(pageNumber,pageSize)); ;
}



这是mvc中的分页代码

解决方案

'??'是null coalesce运算符。

这意味着返回'page'变量的值,除非它为null;如果page为null,则返回1.



??运营商(C#参考) [ ^ ]

My code

public ActionResult commenter(int? page)
       {
           List<comment> c = db.comments.ToList();
           int pageSize = 3;
           int pageNumber = (page ?? 1);
           return View(c.ToPagedList(pageNumber, pageSize)); ;
       }


This is the code for paging in mvc

解决方案

'??' is the null coalesce operator.
It means that the value of the 'page' variable is returned, unless it is null; if page is null, 1 will be returned.

?? Operator (C# Reference)[^]


这篇关于页面是什么?1具体做了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆