我正在尝试将函数从 C# 重写为 VB.NET,并在调试时遇到问题
C#
private static List<string[]> GroupFiles(string extension, int groupNum, bool ignoreStichInName = false)
{
string[] filePaths = Directory.GetFiles(Directory.GetCurrentDirectory(), extension, SearchOption.TopDirectoryOnly);
if (ignoreStichInName)
filePaths = filePaths.Where(f => !IsStitchResult(Path.GetFileName(f))).ToArray();
return filePaths.Select((value, index) => new { value, index }).GroupBy(x => x.index / groupNum, x => Path.GetFileName(x.value)).Select(g => g.ToArray()).ToList();
}
VB.NET
Public Function GroupFiles(pi_sExtension As String, pi_iGroupNum As Integer, pi_bIgnoreStichInName As Boolean) As List(Of String())
Dim l_sFilePath() As String = Directory.GetFiles(Directory.GetCurrentDirectory, pi_sExtension, SearchOption.TopDirectoryOnly)
If pi_bIgnoreStichInName Then
l_sFilePath = l_sFilePath.Where(Function(f) Not (IsStitchResult(Path.GetFileName(f)))).ToArray
End If
Return l_sFilePath.Select(Function(value, index) {value, index}.GroupBy(Function(x) x.index / pi_iGroupNum, Function(x) Path.GetFileName(x.value)).Select(Function(g) g.ToArray().ToList))
End Function
抛出一个错误Return l_sFilePath.Select
"<SelectIterator>d__7`2[System.String,System.Collections.Generic.IEnumerable`1[System.Collections.Generic.List`1[System.String]]]
我不太明白如何正确重写这个Return
,因为Function(value, index)
我像这样重写了代码并且它起作用了。