我只需要知道如何将 lambda 表达式 C# 转换为 vb.net。
if ((object)publicProperties != null && publicProperties.Any())
{
return publicProperties.All(p =>
{
var left = p.GetValue(this, null);
var right = p.GetValue(other, null);
if (typeof(TValueObject).IsAssignableFrom(left.GetType()))
{
//check not self-references...
return Object.ReferenceEquals(left, right);
}
else
return left.Equals(right);
});
}
在vb中,表达式如下我,
Dim left = Nothing
Dim Right = Nothing
If DirectCast(publicProperties, Object) IsNot Nothing AndAlso publicProperties.Any() Then
Return publicProperties.All(Function(p) (left() = p.GetValue(Me, Nothing))(Right() = p.GetValue(other, Nothing)))
If GetType(TValueObject).IsAssignableFrom(left.[GetType]()) Then
'check not self-references...
Return [Object].ReferenceEquals(left, Right)
Else
Return left.Equals(Right)
End If
Else
Return True
End If
我想知道这个表达是否正确,谢谢