Jump to content

Help With C#


JrMasterModelBuilder
 Share

Recommended Posts

JrMasterModelBuilder

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

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

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

JrMasterModelBuilder

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

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

JrMasterModelBuilder

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

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

Sweet.

Have fun c++ing :)

Link to comment
Share on other sites

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

Fantastic! Enjoy using the much better programming language!

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.