System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())

解决方案 »

  1.   

    谢谢大哥的指教,
    是不是这样呀?
    using System;
    using System.Net;
    using System.IO;
    using System.Data;
    using System.Net.Dns;
    using System.Text;
    namespace CwpSoft.NetIP
    {
      public class NetIP
      {
        static void Main()
        {
           Console.WriteLine("IP:{0}",System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()));
        }
      }
    }
    可 以 在 控 制 台 中 输 出 吗 ?
      

  2.   

    dns怎么没有GetHostAddresses方法呢
      

  3.   

    public   string   GetLocalIP()   
      {   
      string   sHostName=System.Net.Dns.GetHostName();     
      System.Net.IPHostEntry     hostinfo=System.Net.Dns.GetHostByName(sHostName);   
      System.Net.IPAddress     add=hostinfo.AddressList[0];   
      return   add.ToString();   
      }
      

  4.   

    IPHostEntry selfIP = Dns.GetHostEntry(Dns.GetHostName());
    IPEndPoint commonAccessIp = new IPEndPoint(selfIP.AddressList[0], 2000);
      

  5.   

    Request.ServerVariables["REMOTE_ADDR"];
      

  6.   

    我想用C#编写一个探测局域网IP地址Windows窗口应用程序
    using System;
    using System.Windows.Forms;
    using System.Net;
    using System.Drawing;
    using System.IO;
    using System.Data
    namespace NetIP
    {
       class NetworkIP:System.Windows.Forms.Form
       {
          public NetworIP
          {
              netIPForm()
           }
           private void NetworIP
           {
           }
       }
    }
      

  7.   

    //我想用C#编写一个探测局域网IP地址Windows窗口应用程序
    using System;
    using System.Windows.Forms;
    using System.Net;
    using System.Drawing;
    using System.IO;
    using System.Data;
    namespace NetIP
    {
       class NetworkIP:System.Windows.Forms.Form
       {
          //private System.Net.Dns.GetHostAddresses IPv6str;  
          private System.Windows.Forms.Label IPnamelab;
          private System.Windows.Forms.TextBox IPtext;      public NetworkIP()
          {
              netIPForm();
           }
           private void netIPForm()
           {          //
              //IPnamelab
              // 
     
              this.IPnamelab=new System.Windows.Forms.Label();
              this.IPnamelab.Location =new Point(10,20);
              this.IPnamelab.Size = new Size(160,20);
              this.IPnamelab.Text = "您自己的IP地址(IPv6):";
              //
              //IPtext
              //
              this.IPtext=new System.Windows.Forms.TextBox();
              this.IPtext.Location = new Point(165,20);
              this.IPtext.Size = new Size(200,20);
              //this.IPtext.Text =System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());// 无法进行隐形转换为string;         //
             //NetIP
             //
             this.Text="局域网IP地址探测程序";
          
             this.Controls.Add(IPnamelab);
             this.Controls.Add(IPtext);
           }
           static void Main()
           {
             Application.Run(new NetworkIP());
           }
       }
    }
      

  8.   

    为什么我在输出时有这个错误?
    using 命名空间指令只能应用于命名空间;“System.Net.Dns”是一个类型,而不是命名空间
    这个应该怎么改?