Reputation: 4042
The strings are identical but when passed as a variable it is not valid?
What the hell is going on? Is it a language bug? I'm running this in C# .Net Core
var postUrl = "http://www.contoso.com";
var postUri = new Uri("http://www.contoso.com"); // works
var uri = new Uri(postUrl); // does not work
Upvotes: 1
Views: 3631
Reputation: 875
If you pulling your hair, then it because there is space after first opening quote in postUrl. Please remove that space & your bug will be begone.
Upvotes: 8
Reputation: 4042
Worked around the problem by using.
var postUrl = "http://www.contoso.com";
var uriBuilder = new UriBuilder(postUrl);
var uri = uriBuilder.Uri
Still wondering wtf?
Just the daily wtf of a programmer doing his job.
Upvotes: 0