VB.NET 中的ref 和C#中的ref 格式区别

今天把一个VB.NET的程序翻成C#的,在ref这堵了半天。

函数定义是这样的:

Public Shared Function GetUsers(ByVal portalId As IntegerByVal isHydrated As BooleanByVal pageIndex As IntegerByVal pageSize As IntegerByRef totalRecords As IntegerAs ArrayList

在VB.NET中可以这样引用:

Users = UserController.GetUsers(UsersPortalId, False, CurrentPage - 1, PageSize, TotalRecords)

但在C#中,引用要加上"ref",参见MSDN: ref(C# 参考)

Users = UserController.GetUsers(UsersPortalId, false, CurrentPage-1, PageSize, ref TotalRecords);

原文地址:https://www.cnblogs.com/DotNetNuke/p/588093.html