0

I have 2 dynamic variables with the same values. But when I try to write out if they are equal the answer is

False

Can you please help me solve my problem I can't figure it out...

The code:

Console.WriteLine(originalDataDyn.suplovanie == dataDyn.suplovanie);

Variable value:

{[
  {
    "trieda": "I.AA ➔ Odpadlo",
    "hodina": "7",
    "ucebna": "S4 - 1C1032 ➔ Odpadlo",
    "poznamka": "",
    "ucitel": "ANT ➔ Odpadlo",
    "predmet": "NJV ➔ Odpadlo"
  },
  {
    "trieda": "I.AE",
    "hodina": "2",
    "ucebna": "4.AT - 1B001",
    "poznamka": "",
    "ucitel": "DEK ➔ KES",
    "predmet": "MAT ➔ INF"
  },
  {
    "trieda": "",
    "hodina": "3",
    "ucebna": "DGEL - 6B107, DURB - 1RUO, USVA - 1F203, +DMOL - 6B106",
    "poznamka": "",
    "ucitel": "GEL, SVA, VER ➔ MOL",
    "predmet": "PRA"
  },
  {
    "trieda": "",
    "hodina": "4",
    "ucebna": "DGEL - 6B107, DURB - 1RUO, USVA - 1F203, +DMOL - 6B106",
    "poznamka": "",
    "ucitel": "GEL, SVA, VER ➔ MOL",
    "predmet": "PRA"
  },
  {
    "trieda": "",
    "hodina": "5",
    "ucebna": "DGEL - 6B107, DURB - 1RUO, USVA - 1F203, +DMOL - 6B106",
    "poznamka": "",
    "ucitel": "GEL, SVA, VER ➔ MOL",
    "predmet": "PRA"
  },
  {
    "trieda": "I.BE",
    "hodina": "3",
    "ucebna": "2.DA - 1D001",
    "poznamka": "nahradená 7. hod. z 1.12.2016",
    "ucitel": "DEK ➔ VES",
    "predmet": "MAT ➔ SJL"
  }
]}

1 Answers1

0

Probably the == is performing an object comparison, and since those are two different objects the comparison fails. Please try one of the following:

originalDataDyn.suplovanie.ToString() == dataDyn.suplovanie.ToString()

or

originalDataDyn.suplovanie.Equals(dataDyn.suplovanie)
Wagner DosAnjos
  • 6,304
  • 1
  • 15
  • 29