我有 2 个 ForEach 循环,我正在尝试将它们转换为一个 Linq:
Dim result As Type = Nothing
For Each AssemblyItem As Reflection.Assembly In AppDomain.CurrentDomain.GetAssemblies
For Each typeItem As Type In AssemblyItem.GetTypes
If myClass.FullName = typeItem.FullName Then
result = typeItem
Exit For
End If
Next
If Not IsNothing(result) Then
Exit For
End If
Next
目前我有:
result = AppDomain.CurrentDomain.GetAssemblies()
.ForEach(Sub(x As Reflection.Assembly)
x.GetTypes().ForEach(Sub(t As Type)
t.FullName = catalogEntity))
我还尝试了另一种没有运气的方法:
result = AppDomain.CurrentDomain.GetAssemblies()
.Select(Sub(x) x.GetTypes()
.Select(Function(y) y.GetType())
.Where(Function(z) z.FullName.Equals(catalogEntity.FullName))).FirstOrDefault()
但我收到以下错误:
未为“Public Shared Sub ForEach(Of T)(array() As T, action As System.Action(Of T))”的参数“action”指定参数
任何帮助将不胜感激,在此先感谢!