Problems with ".Equals()" in listview code
C#
1
Posts
1
Posters
0
Views
1
Watching
-
The following is a chunk of code that I can't get to evaluate properly: if( (lv.Tag.ToString().Equals((object)"dir")) ) { MessageBox.Show("it's a dir") } else { MessageBox.Show("it's a file") } For example, if the value of "lv.Tag.ToString()" is "file", the expression evaluates to "true" and the "dir" branch is entered, so it thinks "file" an "dir" are equal. if I change the chunk of code to reverse the logic like this: if( (lv.Tag.ToString().Equals((object)"file")) ) { MessageBox.Show("it's a file") } else { MessageBox.Show("it's a dir") } and send it a "dir" for the value of lv.Tag.ToString(), it evaluates to "false" and jumps to the proper logic... Is this a known problem or am I doing something wrong...?? thanks.