Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot implicitly convert type System.Uri to string

Tags:

string

c#

I am trying to set the Text property of a TextBox to the Url property of a WebBrowser. The code I have is:

textBox1.Text = webBrowser1.Url;

Visual Studio says:

"Cannot implicitly convert type System.Uri to string"

How do I set the textBox1.Text property to the value of the webBrowser1.Url?

like image 233
House Avatar asked Jun 16 '26 14:06

House


2 Answers

You just need to call the ToString method:

textBox1.Text = webBrowser1.Url.ToString();
like image 130
Rufus L Avatar answered Jun 19 '26 05:06

Rufus L


The webBrowser1.Url is of type System.Uri. To assign it to textbox, which is oftype string you can simply do a webBrowser1.Url.ToString() or use in-built properties like AbsoluteUri, OriginalString etc. depending on your requirement. For complete list of properties refer this MSDN link.

like image 39
Ankit Vijay Avatar answered Jun 19 '26 03:06

Ankit Vijay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!