Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. select domain name part of a url saved in a string

select domain name part of a url saved in a string

Scheduled Pinned Locked Moved C#
questioncom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Farhad Eft
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • F Farhad Eft

      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

      R Offline
      R Offline
      Ryan Bost
      wrote on last edited by
      #2

      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

      F 1 Reply Last reply
      0
      • R Ryan Bost

        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

        F Offline
        F Offline
        Farhad Eft
        wrote on last edited by
        #3

        wow! i was never knew about Uri! thank you so much!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups