.net - C# difference between == and Equals() -
I have a condition in the Silverlight application that compares 2 strings, for some reason when I = = returns false , while .Equals () returns true .
Here is the code:
if ((ListBoxItem) lstBaseMenu.SelectedItem) .content.Equals ("Energy Attack")) // // Execute code} if ( (ListBoxItem) lstBaseMenu.SelectedItem. Content == "energy attack") {// Accusative code} Any reason as to why this is happening?
when == is used to type object If it is done on expression, then it will be solved.
behaves just like a virtual method and so on, so the override version will be used (which compares the content for the string type is).
Comments
Post a Comment