What is the purpose of the Uri class?

3

What is the Uri class and what is its purpose and where should I use it?

Can not pass an object from it to a string variable see in the example:

String caminho = new Uri(@"c:\Windows");

Generate the following error:

  

Error 1 Can not implicitly convert type 'System.Uri' to 'string'

I read about that is used in strings , but I'm confused by that.

    
asked by anonymous 10.03.2016 / 01:30

1 answer

8

I have already replied what is URI .

In the background is a canonical "address" of a resource. And use where you need such an address. If you need an address for a web page, a file path, a reference that has a pattern of where you are and what is that.

Obviously it has a format and rules of what you can have there.

Not used in strings . It is possible to get a string generated with the contents of a URI. Like creating a URI by trying parse a string .

The syntax is clearly incorrect. You are creating an object of type Uri and trying to save it in a type String . It does not work.

documentation might help something.     

10.03.2016 / 02:17