Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problems with ".Equals()" in listview code

Problems with ".Equals()" in listview code

Scheduled Pinned Locked Moved C#
helptutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vlusardi
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups