Understanding Assignment / Comparison of vb.net

This is my first time on Stack Overflow, and I'm trying to figure out what the '=' means in the last line of this code:

Dim label As Label = Me.labels.Item(String.Concat(New Object() { movimiento.Sector1.ID, "-", movimiento.X1, "-", movimiento.Y1 }))
Dim dictionary As Dictionary(Of Label, Integer)
Dim label3 As Label
dictionary = Me.demandas2.Item(label3 = label) = (dictionary.Item(label3) - 1)

Any help would be appreciated, thanks in advance!

+3
source share
3 answers

Thank you all. This snippet was the result of decompiling the dll. I tried to help a partner.

The .Net reflector was decompiled based on the VB.Net code, it was an error. Finally, we see that it must first be decompiled using C # code, which gives a completely different meaning to the code:

if (movimiento.Contenedor.Demanda2)
    {
        Dictionary<Label, int> dictionary;
        Label label3;
        (dictionary = this.demandas2)[label3 = label] = dictionary[label3] - 1;
        if (this.demandas2[label] == 0)
        {
            label.ForeColor = Color.Black;
        }
        (dictionary = this.demandas2)[label3 = label2] = dictionary[label3] + 1;
        label2.ForeColor = Color.DarkOrange;
    }
0
source

(=) VB.NET. , . , , . , , :

Dim x As Integer = 1
Dim y As Integer = 2
Dim z As Integer = x = y

, , , #, x, y z 2. VB . :

If x = y Then
    z = True
Else
    z = False
End If

, . Option Strict On ( ), . , , , :

z = CInt(x = y)

, , , VB.NET. , , , , Option Strict. , :

Dim temp1 As Boolean = (label3 = label) ' Evaluates to False
Dim temp2 As Boolean = (Me.demandas2.Item(temp1) = (dictionary.Item(label3) - 1)) ' Likely evaluates to False
dictionary = temp2 ' Couldn't possibly be a valid assignment
+12

:

dictionary = Me.demandas2.Item(label3 = label) = (dictionary.Item(label3) - 1)

= - . . :

Me.demandas2.Item(label3 = label) = (dictionary.Item(label3) - 1)

= , . "" . :

Me.demandas2.Item(label3 = label)

Once again, the sign =here does the comparison, so if it label3matches label, then the code will be equivalent Me.semandas2.Item(True). That seems weird.

In general, this code does not make much sense, and I would be surprised if it compiles, given that it is trying to assign a logical value to the dictionary. It certainly does not compile with Option Strict On.

+1
source

All Articles