JrMasterModelBuilder Posted August 20, 2011 Share Posted August 20, 2011 I'm a bit new to C#, but having used many other coding languages, I have never found such an inexplicable problem before, and I was hoping someone might be able to tell me a way around it or maybe even explain why. Basically, despite comparing the strings and variable types myself may times, I still can't explain the following C# behavior. var uri = new Uri("C:\\folder\\file.swf"); string path = uri.AbsoluteUri; //This will not work. if (path == "file:///C:/folder/file.swf") { MessageBox.Show("EGUAL 1"); } //Let's try hard coding it. path = "file:///C:/folder/file.swf"; //This one will work. if (path == "file:///C:/folder/file.swf") { MessageBox.Show("EGUAL 2"); } The functions I want to use work only with the hard coded method for reasons I can't explain. Obviously, I need the paths to be dynamic or it won't work for anyone else, so what can I do? Link to comment Share on other sites More sharing options...
Addictgamer Posted August 20, 2011 Share Posted August 20, 2011 If I'm not mistaken, you must convert uri.AbsoluteUri to a string. Maybe a simply cast, string path = (string)uri.AbsoluteUri; Or maybe a function's required to do that. Link to comment Share on other sites More sharing options...
Sharkly Posted August 20, 2011 Share Posted August 20, 2011 See sharp is kind of a pointless language if you ask me, but whatever floats your boat. Link to comment Share on other sites More sharing options...
McJobless Posted August 20, 2011 Share Posted August 20, 2011 See sharp is kind of a pointless language if you ask me, but whatever floats your boat. lol float Yeah, I'm with this guy. Stick to C or C++...much better, and more widely recognised as great programming languages. Link to comment Share on other sites More sharing options...
JrMasterModelBuilder Posted August 21, 2011 Author Share Posted August 21, 2011 If I'm not mistaken, you must convert uri.AbsoluteUri to a string. Maybe a simply cast, string path = (string)uri.AbsoluteUri; Or maybe a function's required to do that. Thanks for the suggestion, but I tried ever different way of converting it to a string I could find, and none of them seemed to make a difference. Outputting the variable type on both returned System.String. It's like there isn't a difference, but there is. See sharp is kind of a pointless language if you ask me, but whatever floats your boat. lol float Yeah, I'm with this guy. Stick to C or C++...much better, and more widely recognised as great programming languages. I'd love to! Too bad some other people decided to make libraries and stuff only for C#. . . Link to comment Share on other sites More sharing options...
Addictgamer Posted August 21, 2011 Share Posted August 21, 2011 Ok then, something else is probably the problem. How about trying string.compare()? That might be a valid workaround. Link to comment Share on other sites More sharing options...
JrMasterModelBuilder Posted August 22, 2011 Author Share Posted August 22, 2011 Thanks for the help, but I just found a way to do it with C++ instead! Screw you C# and your inexplicable inability to do something simple! :D Link to comment Share on other sites More sharing options...
Addictgamer Posted August 22, 2011 Share Posted August 22, 2011 Thanks for the help, but I just found a way to do it with C++ instead! Screw you C# and your inexplicable inability to do something simple! Sweet. Have fun c++ing :) Link to comment Share on other sites More sharing options...
McJobless Posted August 22, 2011 Share Posted August 22, 2011 Thanks for the help, but I just found a way to do it with C++ instead! Screw you C# and your inexplicable inability to do something simple! Fantastic! Enjoy using the much better programming language! Link to comment Share on other sites More sharing options...
Recommended Posts