什么是VB.Net代码来过滤字符串数组?
我使用以下代码
Imports System.Reflection
Dim ass As Assembly = Assembly.GetExecutingAssembly()
Dim resourceName() As String = ass.GetManifestResourceNames()
返回一个String数组
如何过滤resourceName()变量?
我尝试了以下代码行
Dim sNameList() As String
= resourceName.FindAll(Function(x As String) x.EndsWith("JavaScript.js"))
但是编译器返回以下错误
BC36625: Lambda expression cannot be converted to 'T()' because 'T()' is not a delegate type
我该如何纠正该错误? 还有其他解决方案可以解决我的问题吗?
In that case,
sNameList
is anIEnumerable(Of String)
, which is all you need if you intend to use aFor Each
loop over it. If you genuinely need an array:The reason that your existing code didn't work is that
Array.FindAll
isShared
and so you call it on theArray
class, not an array instance: