Are string.Equals() and == operator really same?
241
Are they really same? Today, I ran into this problem. Here is the dump from the Immediate Window:
?s
"Category"
?tvi.Header
"Category"
?s == tvi.Header
false
?s.Equals(tvi.Header)
true
?s == tvi.Header.ToString()
true
So, both s and tvi.Header contain "Category", but == returns false and Equals() returns true.
s is defined as string, tvi.Header is actually a WPF TreeViewItem.Header. So, why are they returning different results? I always thought that they were interchangable in C#.
Can anybody explain why this is?