Reputation: 3
This is what I am trying to do.
I keep getting Cannot implicitly convert type 'System.Uri' to 'string'
and I have tried a few things but can't get my head around it.
string url;
try
{
if (webBrowser1.Url != null)
{
// url = webBrowser1.Url;
MessageBox.Show("Success!");
}
else
{
MessageBox.Show(":(!");
}
}
catch
{
MessageBox.Show("Something Screwed Up");
}
Now at this point I get :(
when I comment out the error. This is on form1.cs - should I be doing this on program.cs? It seems like the object may not be created a the point when I check but I have no idea. By default the form loads with a URL pre-loaded.
Upvotes: 0
Views: 3518
Reputation: 7197
webBrowser1.Url
is URI
object
url
is String
object
it tells you those are diffrent types and there no implicit convertion
url = webBrowser1.Url.ToString();
see great article:
http://msdn.microsoft.com/en-us/library/ms173105.aspx
Upvotes: 4