我的班级中有一个方法,它返回一个数据列表
Private Function GetCertificationLevels()
Dim theProgramYearID As Int32 = Convert.ToInt32(lstProgramYear.SelectedValue)
Dim thePositionGroupID As Int32 = Convert.ToInt32(lstPositionGroup.Selected)
Dim theCategoryID As Int32 = Convert.ToInt32(lstCategory.SelectedValue)
filterLevels = _curTree.GetCertificationLevelsList(theProgramYearID, thePositionGroupID, theCategoryID)
Return filterLevels
End Function
我想只检索_data值( 5261,5263,5262,5264和5260 )
如何进行?
答案 0 :(得分:1)
如果我理解您的问题,那么您正尝试在另一个过程中使用变量theProgramYearID
,thePositionGroupID
和theCategoryID
的值。我将创建一个包含ByRef
参数的重载过程,然后在另一个过程中使用它们。
Private Sub CallingProcedure()
'Declare variables to hold the ByRef results.
Dim locYearID, locGroupID, locCategoryID as Integer
'Call the procedure, and pass the variables for processing
Dim FunctionResult = GetCertificationLevels(locYearID, locGroupID, locCategoryID)
'Now do whatever you need with the modified variables
SomeOtherProcedure()
End Sub
Private Overloads Function GetCertificationLevels(ByRef theProgramYearID as Int32, ByRef thePositionGroupID as Int32, ByRef theCategoryID as Int32)
theProgramYearID = Convert.ToInt32(lstProgramYear.SelectedValue)
thePositionGroupID = Convert.ToInt32(lstPositionGroup.Selected)
theCategoryID = Convert.ToInt32(lstCategory.SelectedValue)
filterLevels = _curTree.GetCertificationLevelsList(theProgramYearID, thePositionGroupID, theCategoryID)
Return filterLevels
End Function
ByRef
将确保函数正在修改传递给它的变量,并且它们将在函数中分配给它们的值。
答案 1 :(得分:0)
使用LINQ:
Return filterLevels.Select(Function(t) t.Data).ToList()