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. Try to display the IP address, but failed....

Try to display the IP address, but failed....

Scheduled Pinned Locked Moved C#
csharpvisual-studiodebuggingquestion
5 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.
  • D Offline
    D Offline
    DotNet
    wrote on last edited by
    #1

    Hi... using System.Net; In the Main Program, I declared... String strHostName = Dns.GetHostName(); IPAddress[] add1 = Dns.GetHostAddresses(strHostName); // <- set a breakpoint Console.WriteLine("Local Machine: " + add1); In the Locals Dialog box of Visual Studio 2005, I found the value of add1[1] is {15.854.457.47} and type: System.Net.Address. Have any idea to grab this IP Address? Thanks.

    G 1 Reply Last reply
    0
    • D DotNet

      Hi... using System.Net; In the Main Program, I declared... String strHostName = Dns.GetHostName(); IPAddress[] add1 = Dns.GetHostAddresses(strHostName); // <- set a breakpoint Console.WriteLine("Local Machine: " + add1); In the Locals Dialog box of Visual Studio 2005, I found the value of add1[1] is {15.854.457.47} and type: System.Net.Address. Have any idea to grab this IP Address? Thanks.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      What do you mean specifically by "grab it"? You have it in a variable, what do you want to do with it?

      Experience is the sum of all the mistakes you have done.

      D 1 Reply Last reply
      0
      • G Guffa

        What do you mean specifically by "grab it"? You have it in a variable, what do you want to do with it?

        Experience is the sum of all the mistakes you have done.

        D Offline
        D Offline
        DotNet
        wrote on last edited by
        #3

        Grab it n display. For example, Console.WriteLine( 'the IP Address' );

        G 1 Reply Last reply
        0
        • D DotNet

          Grab it n display. For example, Console.WriteLine( 'the IP Address' );

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          It looks too obvious, so I don't know if this is what you want: Console.WriteLine("Local Machine: " + add1[1]);

          Experience is the sum of all the mistakes you have done.

          D 1 Reply Last reply
          0
          • G Guffa

            It looks too obvious, so I don't know if this is what you want: Console.WriteLine("Local Machine: " + add1[1]);

            Experience is the sum of all the mistakes you have done.

            D Offline
            D Offline
            DotNet
            wrote on last edited by
            #5

            thanks Guffa....

            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