select domain name part of a url saved in a string
C#
3
Posts
2
Posters
0
Views
1
Watching
-
hey guys i have a URL saved in a string like http://codeproject.com/something.htm i'd only like to select the domain name part of it (codeproject.com) how can i do it? page link can also be http://www.code... or www.code... thank you
-
hey guys i have a URL saved in a string like http://codeproject.com/something.htm i'd only like to select the domain name part of it (codeproject.com) how can i do it? page link can also be http://www.code... or www.code... thank you
-
Create a Uri object with your stored string. Then access the Host property. Example:
Uri url = new Uri("http://www.codeproject.com"); string domainName = url.Host;
Ryan Bost
wow! i was never knew about Uri! thank you so much!