serhio
serhio

Reputation: 28586

Operator = is not defined for types UIElement and UIElement ..?

I translate from C# some code into VB.NET, (WPF, .NET 4)

C#

// 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-translated)

' 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)

Compile 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 - NOT(?)

Upvotes: 3

Views: 528

Answers (1)

Dave
Dave

Reputation: 3621

Try using childElement.Equals(element) instead

Upvotes: 1

Related Questions