this

wrost 2012-10-10 10:13:24
public static PagedList<T> ToPagedList<T>
(
this IQueryable<T> allItems,
int pageIndex,
int pageSize
)
这种表示结构,该怎么解释,为什么把this IQueryable<T> allItems 写到参数里边?? 我知道 使用的时候可以 IQueryable<T>对象.ToPagedList(pageIndex,pageSize)



public static class PageLinqExtensions
{
public static PagedList<T> ToPagedList<T>
(
this IQueryable<T> allItems,
int pageIndex,
int pageSize
)
{
if (pageIndex < 1)
pageIndex = 1;
var itemIndex = (pageIndex-1) * pageSize;
var pageOfItems = allItems.Skip(itemIndex).Take(pageSize);
var totalItemCount = allItems.Count();
return new PagedList<T>(pageOfItems, pageIndex, pageSize, totalItemCount);
}
}

...全文
72 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wrost 2012-10-10
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

扩展方法,就是给已存在的类型添加方法。参见:、
http://technet.microsoft.com/zh-cn/ie/bb383977
[/Quote]

谢谢 :)
dalmeeme 2012-10-10
  • 打赏
  • 举报
回复
扩展方法,就是给已存在的类型添加方法。参见:、
http://technet.microsoft.com/zh-cn/ie/bb383977

wrost 2012-10-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

这个叫“扩展方法”,C# 3.0新增语法,具体什么是扩展方法,可以自己MSDN下。
[/Quote]

谢谢 :) 知道怎么去查就好了
threenewbee 2012-10-10
  • 打赏
  • 举报
回复
这个叫“扩展方法”,C# 3.0新增语法,具体什么是扩展方法,可以自己MSDN下。
Installing c++/g++ on Windows Disclaimer: This page is being maintained mainly for my students. Use these instructions at your own risk. There is no warranty in any form or shape whatsoever!. There is no guarantee that these instructions are up-to-date. With that understood you may continue with the rest of this page if you choose to accept these terms. This page was last updated on September 13, 2005, but still good as of April 30, 2009. Follow these steps to install g++ (the GNU C++ compiler) for Windows. There is no room for creativity here; you must follow the directions exactly. Pick the drive and a folder in which you want to install g++. I'll assume that it is C:, but you can choose a different one. If you choose a different drive or a different folder, you'll need to adapt the directions below accordingly. Download full.exe, an about 14 megabyte executable, to C:\full.exe by right-clicking on the link. Use Save Link As... or Save Target As... Be sure the browser saves the file as C:\full.exe. Run the downloaded executable. This will install g++ (and a lot of other things that you don't really need) on your hard drive. Go to the C: drive using Windows Explorer and double-click on full.exe. Or, open a DOS window (Start > Programs > Command Prompt), connect to the C: drive using the cd command, and type full. Locate where the bin folder was created for the g++ installation. On my Windows XP machine, it was created in the following path: C:\cygnus\cygwin-b20\H-i586-cygwin32\bin You now should add it to the PATH environment variable. You do that by following: Start -> Control Panel -> System -> Advanced -> Environment Variables At this point you can see the PATH variable either in the User Variables or in the System Variables. Add the g++ path into the PATH variable. You add it to the end of the existing value separated by a semicolon (';'). Make sure that you do not lose the original value. You are just appending more to the end separated by a semicolon. Restart your computer. A Cygnus Solutions entry will appear in your Programs menu, and an icon may appear on your desktop. Don't use them! You will use it using the g++ command on a DOS prompt as explained below. You should now be able to run g++ from a DOS (Command Prompt) window. For example, to compile a file called C:\mine\hello.cpp, connect to the C:\mine folder and enter g++ -g hello.cpp -o hello -lm You'll then be able to run the compiled program by entering hello in the DOS window. If you've installed Emacs as described here, you will also be able to run g++ from Emacs. If, when you do this, Emacs tries to compile with the command make -k, you made a mistake during the Emacs installation. If you want to learn how to run g++ on emacs, see here. If you'd like to learn more about where this free compiler came from, we downloaded it from an older site of http://sourceware.org/cygwin/. If you wish to clean up a little, you may delete the file: full.exe at this point. Your g++ compiler is installed under C:\cygnus.

62,263

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧