0

How can this be?

enter image description here

What am I missing?

Dmitry Efimenko
  • 10,973
  • 7
  • 62
  • 79

2 Answers2

2

They're currently boxed into object, and those two objects are not the same object, which means == fails. If you unbox them to int, then it will succeed:

(int)model.value == (int)model.metadata.Model // true

Or you could call Equals which should work:

model.value.Equals(model.metadata.Model) // true
Joe Enos
  • 39,478
  • 11
  • 80
  • 136
0

== Operator Only if operands are Value Types and their values are equal, it returns true else false

C# difference between==and .Equals()

Community
  • 1
  • 1
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396