.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

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -