Operator = undefined for the types UIElement and UIElement.?

I have translated from C # some code to VB.NET, (WPF, .NET 4)

FROM#

// Update the Z-Index of every UIElement in the Canvas.
foreach( UIElement childElement in base.Children )
{
    if( childElement == element )
        Canvas.SetZIndex( element, elementNewZIndex );

      

VB.NET (auto-translate)

' Update the Z-Index of every UIElement in the Canvas. '
For Each childElement As UIElement In MyBase.Children
  If childElement = element Then        ' <<<<<<<<<<<<< Compile ERROR '
    Canvas.SetZIndex(element, elementNewZIndex)

      

Compilation error:

Error 4 Operator '=' is not defined for types 'System.Windows.UIElement' and 'System.Windows.UIElement'.

How is it possible that in C # the operator is defined, but in VB.NET it is NOT (?)

+3


source to share


1 answer


Try instead childElement.Equals(element)



+1


source







All Articles