-1

ラムダ式 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

この表現で合ってるかな、ありがとう

4

1 に答える 1

0

VBバージョンはまったく正常に見えません。これを試して:

    If CObj(publicProperties) IsNot Nothing AndAlso publicProperties.Any() Then
        Return publicProperties.All(Function(p)
                'check not self-references... 
            Dim left = p.GetValue(Me, Nothing)
            Dim right = p.GetValue(other, Nothing)
            If GetType(TValueObject).IsAssignableFrom(left.GetType()) Then
                Return Object.ReferenceEquals(left, right)
            Else
                Return left.Equals(right)
            End If
        End Function)
    End If
于 2012-09-25T16:12:59.787 に答える